6
Answers

Call SQL Loader from C#

Datta Kharad

Datta Kharad

13y
19.3k
1
HI
   How to run command SQLLoader Oracle in c#. I am trying for run this SQLLoader, but out of 80000 rows only 71000 rows inserted into table and lastly throwing error "No process is associated with this object." at process1.WaitForExit();. Please tell me how i remove this error. Thanks.
This is my code:

System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;

string strCmdLine;
strCmdLine = @"/C SQLLDR user/pwd@O11G CONTROL=D:\ControlFile.ctl";
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.WaitForExit();
process1.Close();
Answers (6)
0
Vulpes

Vulpes

NA 96k 2.6m 13y
Try this instead:

string strCmdLine;
strCmdLine = @"/C SQLLDR user/pwd@O11G CONTROL=D:\ControlFile.ctl";
System.Diagnostics.Process process1;
process1 = System.Diagnostics.Process.Start("CMD.exe", strCmdLine); // this process is now associated with process1
process1.WaitForExit();
process1.Close();

There's no need to set the EnableRaisingEvents property to false as it's false, by default, anyway.
Accepted
0
Vir W

Vir W

NA 40 1.4k 11y
Thanks Working fine..
0
Datta Kharad

Datta Kharad

NA 1.6k 54.1k 13y
@Vulpes Sir,

       Yes, You are right...no need for this line.

System.Diagnostics.Process process1;
//process1 = new System.Diagnostics.Process();

string strCmdLine = @"/c SQLLDR user/pwd@O11G CONTROL=D:\ControlFile.CTL";
process1=System.Diagnostics.Process.Start("CMD.EXE", strCmdLine);

process1.WaitForExit();
process1.Close();
0
Vulpes

Vulpes

NA 96k 2.6m 13y
Incidentally, Datta, there's no need for this line:

   process1 = new System.Diagnostics.Process();

because the static Process.Start method will create a new Process object anyway and assign it to the variable process1.
0
Datta Kharad

Datta Kharad

NA 1.6k 54.1k 13y
Thanks Vulpes Sir,
         Its working now, B'coz I didn't assign start process to process1 object. This solution I didn't find any other websites. Again thanks for your useful solution.

System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();

string strCmdLine = @"/c SQLLDR user/pwd@O11G CONTROL=D:\ControlFile.CTL";
process1=System.Diagnostics.Process.Start("CMD.EXE", strCmdLine);

process1.WaitForExit();
process1.Close();
0
Datta Kharad

Datta Kharad

NA 1.6k 54.1k 13y
Hi Vulpes Sir,
               I have tried whatever you said, but still getting same error. Please give me appropriate solution. Thanks for replying. 

System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();

string strCmdLine = @"/c SQLLDR user/pwd@O11G CONTROL=D:\ControlFile.CTL";
System.Diagnostics.Process.Start("CMD.EXE", strCmdLine);

process1.WaitForExit();
process1.Close();