嗨根据我的最后一个问题here我尝试编写一个sql编辑器或类似的东西,这样我尝试从C#连接到CMD并执行我的命令。 现在我的问题是我连接到SQLPLUS后,我不能得到SQLPLUS命令,我审查的其他资源不满足我。请问我连接到sqlplus后如何实现我的进程来运行我的sql命令?现在我用这个代码:使用C#执行多个命令行使用相同的进程
//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();
我定制了它。我单独初始化,我创建的进程对象有一次我仍然有问题,跑我使用这些代码对第二个呼叫第二个命令:
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();
在此先感谢
FWIW,这些评论只是噪音... – 2010-05-17 18:07:34
你的意思是你想开始一次的过程,但发送多个命令吗?如果是这样,为什么不发送多个命令从头开始整个过程从头开始每次(双关语不打算,但无论如何有趣) – 2010-05-17 19:17:44
正好... 我只是运行一次sqlplus 后,我给用户/通行证,如果它登录发送Sql.PL命令。 我马有点困惑:( actully每次我尝试连接数据库并运行我的命令需要时间...但我没有任何想法,也许其他软件使用像这样?哈?任何想法? – Amir 2010-05-18 19:37:36