Database register method hangs

pr_kalepr_kale Posts: 5
edited November 9, 2005 1:00PM in SQL Toolkit Previous Versions
I am trying to compare two databases on a remote server. Here is the code i am using (From sample). At the first Register method, the application just hangs. Any solutions?

I tried it by replacing server name with ".", meaning it works with local SQL server. But not with remote server.

*********************
Database db1=new Database();
Database db2=new Database();

db1.Register(new ConnectionProperties("CPSEPICUPG","c003"), Options.Default);
db2.Register(new ConnectionProperties("CPSEPICUPG","textDB71"), Options.Default);

Differences differences=db1.CompareWith(db2, Options.IgnorePermissions);

foreach (Difference difference in differences)
{
if ((difference.Type == DifferenceType.Different) || (difference.Type == DifferenceType.OnlyIn1))
{
Console.WriteLine("{0} {1} {2}", difference.Type.ToString(), difference.DatabaseObjectType.ToString(), difference.Name);
difference.Selected=false;
}
}

db1.Dispose();
db2.Dispose();
*********************

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello,

    The overloaded ConnectionProperties constructor that you have specified indicates that you want to connect to the server using Integrated Security. Is your Windows login allowed access to the database? This certainly would not work over the Internet and you may want to try specifying a SQL security user name and password.

    You may also want to set one or more breakpoints in your code and run them under the debugger, then see how far your code gets.
  • Thanks. I will check on that. Meanwhile i am working with local SQL server.
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    It may also be a good idea to add a statuseventhandler to your database so that you can see how far the registration gets before it hangs...
    private static void main()
    		{
    			Database db=new Database();
    			db.Status+=new StatusEventHandler(StatusCallback);
    			db.Register(new ConnectionProperties(".", "WidgetStaging"),Options.Default);
    			db.Dispose();
    		}
    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);
    			}
    
    		}
    
Sign In or Register to comment.