I\'m sure this question has been answered already, however I was unable to find an answer using the search tool.
Using c# I\'d like to run a .sql file. The sql file
Put the command to execute the sql script into a batch file then run the below code
string batchFileName = @"c:\batosql.bat";
string sqlFileName = @"c:\MySqlScripts.sql";
Process proc = new Process();
proc.StartInfo.FileName = batchFileName;
proc.StartInfo.Arguments = sqlFileName;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.ErrorDialog = false;
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(batchFileName);
proc.Start();
proc.WaitForExit();
if ( proc.ExitCode!= 0 )
in the batch file write something like this (sample for sql server)
osql -E -i %1