Creating a single large deployment script using c#

JatinJatin Posts: 4
Hi,

i am trying to achieve something very similar mentioned in :
http://www.red-gate.com/MessageBoard/vi ... hp?t=19792

But that was is command line, the same when i used in the c# code it is not creating the neccessary deployment script. I am trying to figure out what is wrong in the code but nothing achieved.

here is my code :

// sqlCompareCredentials is the command that has server creds. and path

sqlCompareCredentials = /db1:WidgetStaging /db2:WidgetProduction
/scriptFile: "C:\Scripts Folder\WidgetSyncScript.sql" /force";
string command = sqlCompareCredentials;
command = "C:\\Program Files\\Red Gate\\SQL Compare 10\\sqlcompare " + command;

System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd","/c "+ command);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
procStartInfo.WorkingDirectory = Environment.CurrentDirectory;
procStartInfo.Verb = "runas";

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;

proc.Start();


It is not returning any error but the script file is not getting the desired result.
Any help will be great..!!

Comments

  • The question is resolved now !!
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Thanks for letting us know. I would imagine the command would work normally when you start it from a .NET Process. It probably needed an option set if the script was missing something.
  • The below code is working..yes there were some commands missing.


    sqlCompareCredentials = /db1:WidgetStaging /db2:WidgetProduction
    /scriptFile: "C:\Scripts Folder\WidgetSyncScript.sql" /force";

    command = "sqlcompare " + sqlCompareCredentials;
    System.Diagnostics.Process process = new System.Diagnostics.Process();
    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
    startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    startInfo.WorkingDirectory = sqlCompareDir;
    startInfo.FileName = "cmd.exe";
    startInfo.Arguments = "/C " + command;
    startInfo.Verb = "runas";
    process.StartInfo = startInfo;
    process.Start();
Sign In or Register to comment.