Hello,
How to display list process, when i run sql*loader in c#. I mean when i run sql*loader from cmd windows, i get list process how many row has been inserted. But when i run SQL*Loader from C#, i can't get process SQL*Loader.
This is my code:
string strCmd, strSQLLoader;
string strLoaderFile = "XLLOAD.CTL";
string strLogFile = "XLLOAD_LOG.LOG";
string strCSVPath = @"E:\APT\WorkingFolder\WorkingFolder\sqlloader\sqlloader\bin\Debug\8testskrip_HTTP.csv";
string options = "OPTIONS (SKIP=1, DIRECT=TRUE, ROWS=1000000,BINDSIZE=512000)";
string append = "APPEND INTO TABLE XL_XDR FIELDS TERMINATED BY ','";
string table = "OPTIONALLY ENCLOSED BY '\"' TRAILING NULLCOLS (xdr_id,xdr_type,session_start_time,session_end_time,session_last_update_time,session_flag,version,connection_row_count,error_code,method,host_len,host,url_len,url,connection_start_time,connection_last_update_time,connection_flag,connection_id,total_event_count,tunnel_pair_id,responsiveness_type,client_port,payload_type,virtual_type,vid_client,vid_server,client_addr,server_addr,client_tunnel_addr,server_tunnel_addr,error_code_2,ipid,c2s_pkts,c2s_octets,s2c_pkts,s2c_octets,num_succ_trans,connect_time,total_resp,timeouts,retries,rai,tcp_syns,tcp_syn_acks,tcp_syn_resets,tcp_syn_fins,event_type,flags,time_stamp,event_id,event_code)";
strCmd = "sqlldr xl/secreat@o11g control=" + strLoaderFile + " LOG=" + strLogFile;
System.IO.DirectoryInfo di;
try
{
System.Diagnostics.ProcessStartInfo cmdProcessInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe");
di = new DirectoryInfo(strCSVPath);
strSQLLoader = "";
strSQLLoader += "LOAD DATA INFILE '" + strCSVPath.ToString().Trim() + "' " + append + " " + table;
StreamWriter writer = new StreamWriter(strLoaderFile);
writer.WriteLine(strSQLLoader);
writer.Flush();
writer.Close();
// Redirect both streams so we can write/read them.
cmdProcessInfo.RedirectStandardInput = true;
cmdProcessInfo.RedirectStandardOutput = true;
cmdProcessInfo.UseShellExecute = false;
cmdProcessInfo.LoadUserProfile = true;
//System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
// Start the procses.
System.Diagnostics.Process pro = System.Diagnostics.Process.Start(cmdProcessInfo);
// Issue the dir command.
pro.StandardInput.WriteLine(strCmd);
// Exit the application.
pro.StandardInput.WriteLine("exit");
//Process[] processlist = Process.GetProcesses();
//foreach(Process pro in processlist){
Console.WriteLine("Process: {0} ID: {1}", pro.ProcessName, pro.Id);
Console.WriteLine(pro.StandardOutput.ReadLine());
//}
// Read all the output generated from it.
string strOutput;
strOutput = pro.StandardOutput.ReadToEnd();
pro.Dispose();
}
catch (Exception ex)
{
return;
}
finally
{
}
Thanks
Loading

Guest UserRank #1,422 · 1.2K reputationPosted Mar 14, 2011, 4:49 AM EDT
For example, this code will start Notepad from within a C# app. Note that it doesn't start cmd.exe:
Process p = new Process();
p.StartInfo.FileName = @"C:\Windows\notepad.exe";
p.StartInfo.Arguments = @"";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = false;
p.Start();
Vijay YadavRank #1,637 · 943 reputationPosted Mar 14, 2011, 11:36 PM EDT
In the above code i.e. p.StartInfo.FileName = @"C:\Windows\notepad.exe"; here we have to provide the whole path of the exe in order to run the exe, Is there anywhere so that we should provide only exe name or something like this. If any idea please share it.
Guest UserRank #1,422 · 1.2K reputationPosted Mar 15, 2011, 4:51 AM EDT
p.StartInfo.FileName = @"notepad.exe";
Vijay YadavRank #1,637 · 943 reputationPosted Mar 15, 2011, 5:17 AM EDT
Yes for files which are resides in our path. But what about the files which are not resides(that are resides in program files). Do you have any idea regarding this?
Guest UserRank #1,422 · 1.2K reputationPosted Mar 15, 2011, 5:23 AM EDT
You can store this pathname as an AppSetting in the app.config file (so you can change it without having to recompile the app) and retrieve it using ConfigurationManager.AppSettings["my_app_pathname_setting"].
If the exe has its home directory stored in the registry you could also retrieve it from there.
Vijay YadavRank #1,637 · 943 reputationPosted Mar 15, 2011, 6:25 AM EDT
Thanks a lot!!!!:)
Suthish NairRank #92 · 22.8K reputationPosted Mar 16, 2011, 9:55 AM EDT