How to use multiple Options to compare two databases.

EjEj Posts: 3
edited December 12, 2006 4:32AM in SQL Compare Previous Versions
I'm a C# dev using SQL Compare 5.0 to compare two databases named SourceDB and TargetDB. I call the register method on the Database a la

SourceDB.Database.Register(SourceDB.ConxProps, Options.IgnorePermissions);
TargetDB.Database.Register(TargetDB.ConxProps, Options.IgnorePermissions);

I get the difference by calling:

Differences differences = TargetDB.Database.CompareWith(SourceDB.Database, Options.IgnorePermissions);

I now want to ignore permissions and users for both so i figured i'd use the bitwise OR operator on the Options enum as in:

SourceDB.Database.Register(SourceDB.ConxProps, Options.IgnorePermissions | Options.IgnoreUsers );
TargetDB.Database.Register(TargetDB.ConxProps, Options.IgnorePermissions | Options.IgnoreUsers);

and get the difference by using

Differences differences = TargetDB.Database.CompareWith(SourceDB.Database, Options.IgnorePermissions | Options.IgnoreUsers);

This doesn't seem to work as i still have Users in my differences object. I can get rid of them by looping through each Difference object in the differences collection and checking for where DatabaseObjectType == ObjectType.User but surely this is a bit of an overkill. Is there a way i can get round this or is there a glaring mistake in my code? Any help will be appreciated. :shock:

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Ej,

    IgnoreUsers doesn't ignore the users, it only ignores some user attributes on SQL Server 2005 (see the Toolkit documentation for more information).

    You'd exclude the users from the synchronization the same way that you would exclude any other object, which is to loop through the differences as you had done.
  • That did it in the end.
    Thanks Brian
Sign In or Register to comment.