Hi,
I am trying to figure out a way of running an sql script into an sqlexpress server.
I have been looking at the sqlcmd tool, attemping to use this in a spawned process.
example...
this returns an error that a file can't be found. I have checked and the required files are there. I have also taken the command string and manually run it through a cmd window and that works fine. But when I run it from code it won't work.
Any ideas on how to do this?
Cheers.
Kevin.
I am trying to figure out a way of running an sql script into an sqlexpress server.
I have been looking at the sqlcmd tool, attemping to use this in a spawned process.
example...
Code:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + @"sqlcmd .\sqlexpress -i ""C:\Program Files\PCIT\CDEvolution\CreateDB.sql"" -o ""C:\Program Files\PCIT\CDEvolution\CreateDBRes.txt""";
Console.WriteLine(proc.StartInfo.FileName.ToString());
try { proc.Start(); }
catch (Exception e)
{
Console.WriteLine(e.Message);
}
this returns an error that a file can't be found. I have checked and the required files are there. I have also taken the command string and manually run it through a cmd window and that works fine. But when I run it from code it won't work.
Any ideas on how to do this?
Cheers.
Kevin.