Forum guidelines
AuthorQuestion
Call SQL Loader from C#
Posted on: 25 Feb 2012
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();

Please mark as Accepted answer if your query resolved.Thanks & RegardsDatta S. Kharad
AuthorReply
Vulpes
  • 0
  • 0
accepted
Re: Error occurred while Calling SQL Loader from C# Windows Application
Posted on: 26 Feb 2012   Accepted Answer
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.

Re: Error occurred while Calling SQL Loader from C# Windows Application
Posted on: 27 Feb 2012  
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();

Please mark as Accepted answer if your query resolved.Thanks & RegardsDatta S. Kharad
Re: Error occurred while Calling SQL Loader from C# Windows Application
Posted on: 27 Feb 2012  
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();

Please mark as Accepted answer if your query resolved.Thanks & RegardsDatta S. Kharad
Re: Error occurred while Calling SQL Loader from C# Windows Application
Posted on: 27 Feb 2012  
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.

Re: Error occurred while Calling SQL Loader from C# Windows Application
Posted on: 29 Feb 2012  
@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();

Please mark as Accepted answer if your query resolved.Thanks & RegardsDatta S. Kharad
Vir W
  • 0
  • 0
Re: Call SQL Loader from C#
Posted on: 21 May 2013  
Thanks Working fine..

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.