Red Gate forums :: View topic - Write Compare Differences to Scripts Folder
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK Previous Versions
SQL Comparison SDK Previous Versions forum

Write Compare Differences to Scripts Folder

Search in SQL Comparison SDK Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
tater9104



Joined: 12 Feb 2009
Posts: 1

PostPosted: Thu Feb 12, 2009 8:37 pm    Post subject: Write Compare Differences to Scripts Folder Reply with quote

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:
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?

      
   }
}
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6649

PostPosted: Mon Feb 16, 2009 7:46 pm    Post subject: Reply with quote

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/Synchronizing_Schema_-_Live_Database%2C_Scripts_folder

If this isn't clear enough, feel free to let me know.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group