RedGate.SQLCompare.Engine.Differences Issue

Automate and integrate using the SQL comparison API

Moderators: Chris Auckland, David Atkinson, Michelle Taylor, chengvoon.tong

RedGate.SQLCompare.Engine.Differences Issue

Postby rscornette » Thu Jul 12, 2012 6:18 pm

I am attempting to compare two databases utilizing code samples found on the RedGate site; however, I am getting an "Object reference not set to an instance of an object" error in the following line: Differences dbSourceVsdbTarget = dbSource.CompareWith(dbTarget, Options.Default);

The full code snippet is as follows:

using (Database dbSource = new Database(),
dbTarget = new Database())
{
// Retrieve the schema information for the two databases
Console.WriteLine("Registering databases");
dbSource.Register(new ConnectionProperties("vbserve20.libtax.com", "Franchise"), Options.Default);
dbSource.Register(new ConnectionProperties("vbserve18.libtax.com", "Franchise"), Options.Default);

Console.WriteLine("Comparing Databases");
Differences dbSourceVsdbTarget = dbSource.CompareWith(dbTarget, Options.Default);

// Set the filespec for our HTML report
string ReportOutput = @"C:\\Users\\scott.cornette\\Desktop\\htmlreport.html";
// Set the XSL template to use for the report. These ship with the SQL Compare software
string xsltemplate = @"C:\\Program Files (x86)\\Red Gate\\SQL Compare 9\\SQLCompareInteractiveReportTemplate.xsl";

Console.WriteLine("Creating report...");
HTMLReport.CreateHtmlReport(ReportOutput, dbSource, dbTarget, dbSourceVsdbTarget, Options.Default, xsltemplate);

Console.WriteLine("Finished creating {0}, viewing", ReportOutput);
HTMLReport.ViewReport(ReportOutput);
}

Any help would be greatly appreciated. There does not appear to be a constructor available for the Differences collection, so I am not sure what to do.
rscornette
 
Posts: 2
Joined: Thu Jul 12, 2012 6:09 pm

RedGate.SQLCompare.Engine.Differences Issue

Postby rscornette » Thu Jul 12, 2012 6:33 pm

All,

I realized the error of my ways: I inadvertently failed to register the dbTarget object because in my cut-n-paste efforts, I used dbSource twice.

Sorry - problem resolved.
rscornette
 
Posts: 2
Joined: Thu Jul 12, 2012 6:09 pm


Return to SQL Comparison SDK 10

Who is online

Users browsing this forum: No registered users and 0 guests