【发布时间】:2018-10-29 06:42:49
【问题描述】:
我想通过 .net windows 应用程序运行 SQLCMD.EXE,我该如何实现呢?
【问题讨论】:
标签: .net sql-server windows sqlcmd
我想通过 .net windows 应用程序运行 SQLCMD.EXE,我该如何实现呢?
【问题讨论】:
标签: .net sql-server windows sqlcmd
您必须在using System.Diagnostics; 下使用ProcessStartInfo
// Calls the sqlcmd
ProcessStartInfo info = new ProcessStartInfo("sqlcmd", @" -S .\sqlexpress -i C:\YourFileName.sql");
// Indicades if the Operative System shell is used, in this case it is not
info.UseShellExecute = false;
//No new window is required
info.CreateNoWindow = true;
//The windows style will be hidden
info.WindowStyle = ProcessWindowStyle.Hidden;
//The output will be read by the starndar output process
info.RedirectStandardOutput = true;
Process proc = new Process();
proc.StartInfo = info;
//Start the process
proc.Start();
【讨论】: