Red Gate forums :: View topic - Confused by Database Source and Target
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK Previous Versions
SQL Comparison SDK Previous Versions forum

Confused by Database Source and Target

Search in SQL Comparison SDK Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
diesel7633



Joined: 23 Jun 2010
Posts: 3

PostPosted: Tue Jun 29, 2010 4:55 pm    Post subject: Confused by Database Source and Target Reply with quote

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:


 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:
RedGate.SQLDataCompare.Engine.DataCompareUserActions.ReplayUserActions(
                    project.SelectTableActions,
                    project.DataSource1,
                    project.DataSource2,
                    ref mappings);

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

}


This is the SQL Header and the scripts seem reversed:

Code:
/*
Run this script on:

DatabaseA    -  This database will be modified

to synchronize it with:

DatabaseB

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?
Back to top
View user's profile Send private message
diesel7633



Joined: 23 Jun 2010
Posts: 3

PostPosted: Tue Jun 29, 2010 9:09 pm    Post subject: Nevermind Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group