Iterating through many databases

fordc03fordc03 Posts: 49 Bronze 2
edited June 7, 2006 10:47AM in SQL Toolkit Previous Versions
Okay, I seem to be hitting a brick wall on the best way to do this.

We have about 3,000 databases that we apply scripts to on a nightly basis. We have a master database that gets all the updates applied to it and then we need to compare the schema's.

So, it's a 1 to many kind of thing. I have 1 master database that I want to compare to 3,000 children to make sure the build went through and all database schemas are exactly the same.

My question is, it takes a few minutes to register a database, and it locks my application. Probly the way I'm coding it, but I don't know a better way at the moment.

How can I get a status message or percent complete when registering databases? Is that possible?

Comments

  • fordc03fordc03 Posts: 49 Bronze 2
    I'm using C# and VS2005 for my project.
  • This is indeed possible,

    If you have a look at the class Database you can see that it implements ICancellable

    ICancellable has two properties - Cancel() and a Status event which is fired on updates.

    The toolkit samples has an example how to use it:
    		private static void StatusCallback(object sender, StatusEventArgs e)
    		{
    			//fired by the SqlProvider to indicate events
    
    			if (e.Message!=null)
    			{
    				Console.WriteLine(e.Message);
    			}
    
    			if (e.Percentage!=-1)
    			{
    				Console.WriteLine("{0}%", e.Percentage);
    			}
    
    		}
    
    		private static void GetFeedback()
    		{
    			Database db=new Database();
    			db.Status+=new StatusEventHandler(StatusCallback);
    			db.Register(new ConnectionProperties(".", "WidgetStaging"),Options.Default);
    			db.Dispose();
    		}
    

    In the UI we spawn the Register call off onto another thread so the main application can continue to respond to users (and show the progress dialog) and marshall that status event calls back onto the main UI thread to update the UI.

    Hope this helps,

    - James
    --
    James Moore
    Red Gate Software Ltd
    James Moore
    Head of DBA Tools
    Red Gate Software Ltd
  • fordc03fordc03 Posts: 49 Bronze 2
    Thanks, that does help. :)
Sign In or Register to comment.