I trying to compare my live database with snapshot with this code.
When i loop thru the difference my options is not apply. All table with not for replication statement appears.
Thanks
Pascal
Options cmpOption = Options.IgnorePermissions | Options.IgnorePermissions | Options.IgnoreUsers | Options.IgnoreWhiteSpace | Options.IgnoreUserProperties | Options.IgnoreCollations | Options.IgnoreNotForReplication;
RedGate.SQLCompare.Engine.Database db = new RedGate.SQLCompare.Engine.Database();
RedGate.SQLCompare.Engine.Database dbSnapShot = new RedGate.SQLCompare.Engine.Database();
//Set eventHandler to get the status
db.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
trace.WriteTrace(Text.TraceLoadDataBase + config.Server + "\\" + config.Name);
db.Register(new ConnectionProperties(config.Server, config.Name, config.UserId, config.Password), cmpOption);
trace.WriteTrace(Text.TraceLoadSnapShot + snapshot);
dbSnapShot.LoadFromDisk(snapshot);
Differences differences = dbSnapShot.CompareWith(db, cmpOption);
foreach (Difference difference in differences)
{
//make sure the difference is selected so it is included in the synchronization
difference.Selected = true;
}
Work work = new Work();
work.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
//calculate the work to do using options
work.BuildFromDifferences(differences, cmpOption, true);
RedGate.SQL.Shared.ExecutionBlock block = work.ExecutionBlock;
//and run the SQL
RedGate.SQL.Shared.BlockExecutor executor = new RedGate.SQL.Shared.BlockExecutor();
executor.ExecuteBlock(block, config.Server, config.Name,false ,config.UserId, config.Password);
executor.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
//dispose of the objects
block.Dispose();
//dispose of the objects
db.Dispose();
dbSnapShot.Dispose();
When i loop thru the difference my options is not apply. All table with not for replication statement appears.
Thanks
Pascal
Options cmpOption = Options.IgnorePermissions | Options.IgnorePermissions | Options.IgnoreUsers | Options.IgnoreWhiteSpace | Options.IgnoreUserProperties | Options.IgnoreCollations | Options.IgnoreNotForReplication;
RedGate.SQLCompare.Engine.Database db = new RedGate.SQLCompare.Engine.Database();
RedGate.SQLCompare.Engine.Database dbSnapShot = new RedGate.SQLCompare.Engine.Database();
//Set eventHandler to get the status
db.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
trace.WriteTrace(Text.TraceLoadDataBase + config.Server + "\\" + config.Name);
db.Register(new ConnectionProperties(config.Server, config.Name, config.UserId, config.Password), cmpOption);
trace.WriteTrace(Text.TraceLoadSnapShot + snapshot);
dbSnapShot.LoadFromDisk(snapshot);
Differences differences = dbSnapShot.CompareWith(db, cmpOption);
foreach (Difference difference in differences)
{
//make sure the difference is selected so it is included in the synchronization
difference.Selected = true;
}
Work work = new Work();
work.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
//calculate the work to do using options
work.BuildFromDifferences(differences, cmpOption, true);
RedGate.SQL.Shared.ExecutionBlock block = work.ExecutionBlock;
//and run the SQL
RedGate.SQL.Shared.BlockExecutor executor = new RedGate.SQL.Shared.BlockExecutor();
executor.ExecuteBlock(block, config.Server, config.Name,false ,config.UserId, config.Password);
executor.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
//dispose of the objects
block.Dispose();
//dispose of the objects
db.Dispose();
dbSnapShot.Dispose();