How to compare 2 DBases with selected tables
blaz03
Posts: 4
Hi, we just bough your product, and it's great.
Now i decided to write sync data application in c# to automaticly synchronize data between two pretty large databases (each 50 GB). version of Redgate is 5.2.
My problem is that i don't know how can i set the tables which i want to synchronize.
And my second question is how to set options?
i use: SqlOptions sqlOpt = new SqlOptions();
sqlOpt = SqlOptions.DDLTriggerDisable | SqlOptions.UseTransactions..
Where do i need to set this options?
Thank you for your answers..
Best regards
Now i decided to write sync data application in c# to automaticly synchronize data between two pretty large databases (each 50 GB). version of Redgate is 5.2.
My problem is that i don't know how can i set the tables which i want to synchronize.
And my second question is how to set options?
i use: SqlOptions sqlOpt = new SqlOptions();
sqlOpt = SqlOptions.DDLTriggerDisable | SqlOptions.UseTransactions..
Where do i need to set this options?
Thank you for your answers..
Best regards
Comments
Selecting the table whose data you want to compare is a matter of setting the tablemappings:
http://www.red-gate.com/messageboard/vi ... php?t=3060
The gist of this is that you create the default tablemappings as shown in the Toolkit sample code and then you can loop through them and set their 'included' property on and off.
This is how to choose individual tables.
now, i'm having another problem, some tables can't be syncronized
and in some tables only part of the data is syncronized.
If i use DataCompare application i can see the diferences and i can sync them.
But with my C# application it won't go.
Databases all the same, tables are the same and with PKs.
Any hint how to resolve this would be great.
Please help
The example code creates a set of default mappings; tables can only be mapped if they have a matching unique index or constraint column. Columns with different datatypes will not be compared, either.
You'll want to create your own custom tablemappings in code for these tables.
but if i filter mappings, they are not..
Code for setting mappings:
foreach (TableMapping mapping in mappings.TableMappings)
{
if ((mapping.Obj1 != null) && (mapping.Obj1.FullyQualifiedName.ToLower() == "[dbo].[" + tableName + "]"))
{
mapping.Include=true;
}
else
{
mapping.Include = false;
}
}
From the code, I do see one problem: you are using the createmappings method to create the table mappings, then including mappings for certain tables: this leaves the tables that couldn’t be mapped automatically using the createmappings method. Those need to be mapped manually. You can see an example of this in the Data Compare examples.
This is an example of how you would manually create a mapping for a table. This manually-created mapping can then be added to the mappings created automatically using the createmappings method by using the mappings object’s Add method. Hopefully this points you in the right direction.