Confused by Database Source and Target

Automate and integrate using the SQL comparison API

Moderator: Chris Auckland

Confused by Database Source and Target

Postby diesel7633 » Tue Jun 29, 2010 4:55 pm

I'm having trouble understanding which is the source and which is the target in the SQL Data Compare SDK.

I'm loading a project from disk. When I open the project I can see the source (DatabaseA) and target (DatabaseB) database names.

In code I'm doing...

Code: Select all

 Project project = Project.LoadFromDisk(@"myproject.sdc");

using (Database fromDatabase=new Database())
using (Database toDatabase=new Database())
//debugging shows this is DatabaseA
LiveDatabaseSource fromLiveDataSource = project.DataSource1 as LiveDatabaseSource;
ConnectionProperties fromConnectionProperties = fromLiveDataSource.ToConnectionProperties();

//debugging shows this is DatabaseB
LiveDatabaseSource toLiveDataSource = project.DataSource2 as LiveDatabaseSource;
ConnectionProperties toConnectionProperties = toLiveDataSource.ToConnectionProperties();

//excluded exception handling for clarify in forum post
fromDatabase.RegisterForDataCompare(fromConnectionProperties, Options.Default);
toDatabase.RegisterForDataCompare(toConnectionProperties, Options.Default);

So essentially this is what I wanted...I want the changes to take effect on DatabaseB. When I run the statements below and view the scripts that are produced...the databases are switched in the generated SQL header.

Code: Select all
                    ref mappings);

using(ComparisonSession session = new ComparisonSession())
session.CompareDatabases(fromDatabase, toDatabase, mappings);


This is the SQL Header and the scripts seem reversed:

Code: Select all
Run this script on:

DatabaseA    -  This database will be modified

to synchronize it with:


You are recommended to back up your database before running this script

Script created by SQL Data Compare version 8.1.0 from Red Gate Software Ltd at 06/29/2010 10:37:53


Any thoughts?
Posts: 3
Joined: Wed Jun 23, 2010 4:52 pm


Postby diesel7633 » Tue Jun 29, 2010 9:09 pm

Please disregard. I'm still learning the API and I misunderstood the bool runOnTwo for provider.GetMigrationSQL. I initially interpreted it to mean "run it" in addition to getting the SQL script back so I had it set to false, causing it to basically run the script backwards. Once set to true like in the examples, everything worked as anticipated.
Posts: 3
Joined: Wed Jun 23, 2010 4:52 pm

Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests