Write Compare Differences to Scripts Folder

Automate and integrate using the SQL comparison API

Write Compare Differences to Scripts Folder

Postby tater9104 » Thu Feb 12, 2009 8:37 pm

Hey,

I am working on a small executable that allows me to check for a difference between a target live database and a script folder and write any differences to that script folder.

For the most part, I see how to do this, but I am unsure how to write the difference back out to the scripts folder.

Here is my code (note my last comment in this code block):



Code: Select all
using (Database LiveDB = new Database(), ScriptDB = new Database())
{

   LiveDB.Register(new ConnectionProperties(userArgs["s"], userArgs["d"], userArgs["u"], userArgs["p"]), Options.Default);

   ReadFromScriptDatabaseInformation ScriptDBInfo = new ReadFromScriptDatabaseInformation();

   ScriptDB.Register(userArgs["t"], ScriptDBInfo, Options.Default);

   Differences LiveVSScripts = LiveDB.CompareWith(ScriptDB, Options.Default ^ Options.IncludeDependencies);

   foreach (Difference tempDiff in LiveVSScripts)
   {
      tempDiff.Selected = true;
   }

   Work work = new Work();

   work.BuildFromDifferences(LiveVSScripts, Options.Default ^ Options.IncludeDependencies, true);

   //Write out any warnings / messages...
   Console.WriteLine("Messages:");
   foreach (Message message in work.Messages)
   {
      Console.WriteLine(message.Text);
   }

   Console.WriteLine("Warnings:");
   foreach (Message message in work.Warnings)
   {
      Console.WriteLine(message.Text);
   }
   
   using (ExecutionBlock block = work.ExecutionBlock)
   {

      Console.WriteLine("SQL to synchronize:");
      Console.WriteLine(block.GetString());

      BlockExecutor executor = new BlockExecutor();
      
      //What do I do here to write the differnces back out to the scripts file?

      
   }
}
tater9104
 
Posts: 1
Joined: Thu Feb 12, 2009 8:31 pm

Postby Brian Donahue » Mon Feb 16, 2009 7:46 pm

Hi,

Thanks for your post. I believe you can find an example of synchronizing to a script folder on the Comparison SDK wiki:
http://labs.red-gate.com/index.php/Sync ... pts_folder

If this isn't clear enough, feel free to let me know.
Brian Donahue
 
Posts: 6590
Joined: Mon Aug 23, 2004 10:48 am


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests

cron