I am using the following code to execute osql command and then get its output (like 2 rows affected etc) but it never finishes. Please let me know what am I missing.
string sqlFilePath = Helper.GetFilePath(sqlFileName, Environment.CurrentDirectory);
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = @"osql -E -S @Server -d @Database -T -n -i ""@SqlFile"""
.Replace("@Server", ConfigurationManager.AppSettings["Server"])
.Replace("@Database", Path.GetFileNameWithoutExtension(DB))
.Replace("@SqlFile", sqlFilePath);
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();