Options

RedGate.SQLCompare.Engine.Differences Issue

rscornetterscornette Posts: 3
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.

Comments

  • Options
    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.
Sign In or Register to comment.