I am querying the version of sql server using sqlcmd (from my app) and would like to display the info, say, on a rich text box, how do i go about it, here's the code:
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();