title: Execute multiple command lines with the same process using C#
body: <p>Hi according to my last question <a href="https://stackoverflow.com/questions/2846700/how-i-can-verify-my-pl-sql-syntax">here</a> I try to write a sql editor or some thing like this,in this way I try to connect to CMD from C# and execute my command.
  Now my problem is I connect to SQLPLUS after that I cant get SQLPLUS command,and the other resource I review don't satisfy me.  Please help me how after I connected to sqlplus , I can a live my process to run my sql command? right now I use this code:</p>
  
  <pre><code>//Create process
  System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
  
  //strCommand is path and file name of command to run
  pProcess.StartInfo.FileName = strCommand;
  
  //strCommandParameters are parameters to pass to program
  pProcess.StartInfo.Arguments = strCommandParameters;
  
  pProcess.StartInfo.UseShellExecute = false;
  
  //Set output of program to be written to process output stream
  pProcess.StartInfo.RedirectStandardOutput = true;
  
  //Optional
  pProcess.StartInfo.WorkingDirectory = strWorkingDirectory;
  
  //Start the process
  pProcess.Start();
  
  //Get program output
  string strOutput = pProcess.StandardOutput.ReadToEnd();
  
  //Wait for process to finish
  pProcess.WaitForExit();
  </code></pre>
  
  <p>I customized it.  I separate the initialize, I created the process object one time  I still have problem, to run the second command I use these codes for the second call:</p>
  
  <pre><code>pProcess.StartInfo.FileName = strCommand;
  
  //strCommandParameters are parameters to pass to program
  pProcess.StartInfo.Arguments = strCommandParameters;
  //Start the process
  pProcess.Start();
  
  //Get program output
  string strOutput = pProcess.StandardOutput.ReadToEnd();
  
  //Wait for process to finish
  pProcess.WaitForExit();
  </code></pre>
  
  <p>Thanks in advance</p>