我正在使用 sqlcmd (来自我的应用程序)查询 sql server 的版本,并想在富文本框中显示信息,例如,我该如何处理,这是代码:
Process proc = new Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.FileName = "sqlcmd";
proc.StartInfo.Arguments = @"-U sa -P somepassword -q 'SELECT @@VERSION' -S (localhost)\InstanceName";
proc.Start();
StringBuilder q = new StringBuilder();
while (!proc.HasExited)
{
q.Append(proc.StandardOutput.ReadToEnd());
}
string r = q.ToString();
rtbCheckVersion.Text = r;
proc.WaitForExit();