Datta Kharad

Datta Kharad

  • NA
  • 1.6k
  • 52.6k

Call SQL Loader from C# application?

Feb 24 2012 9:17 AM
Hi
   I want to call SQL Loader from c# application, I did it Incomplete. Suppose I have 80000 rows in a table. After call SQL loader from my application, only 12000 rows are inserted into table or sometime 15000 and its take long time for this process. 
My Code:-

Process proc = new Process();
string myCommand = @"CMD.EXE";
proc.StartInfo = new ProcessStartInfo(myCommand);

//Set up arguments for CMD.EXE
proc.StartInfo.Arguments = @"/c SQLLDR user/pwd@oracle CONTROL=D:\ContolFile.CTL";

proc.StartInfo.RedirectStandardOutput = true;

proc.StartInfo.RedirectStandardError = true;

proc.StartInfo.UseShellExecute = false;

proc.StartInfo.WorkingDirectory = @"D:\";
proc.Start();
proc.WaitForExit();
proc.Close();

if (proc.ExitCode == 0) 
{
 MessageBox.Show("Successfully Inserted");
}
else
{
 MessageBox.Show(proc.StandardError.ReadToEnd());
}

       If I will do this manually using Command Line prompt then It will insert 80000 rows in a table. But I want do this in C# application. Please give me appropriate solution.

Answers (2)