"Object reference not set to an instance of an object."
Andy_PS
Posts: 16
Heres my code:
When run this line "work.BuildFromDifferences(differences, Options.None, false);" throws the null reference exception.
Here's the stack trace:
Any thoughts?
Database liveDatabase = new Database(); liveDatabase.RegisterForDataCompare(liveConnectionProperties); Database snapshotDatabase = new Database(); snapshotDatabase.LoadFromDisk(snapshotPath); Differences differences = liveDatabase.CompareWith(snapshotDatabase, Options.None); foreach (Difference difference in differences) { difference.Selected = true; } Work work = new Work(); work.BuildFromDifferences(differences, Options.None, false); ExecutionBlock executionBlock = work.ExecutionBlock; BlockExecutor blockExecutor = new BlockExecutor(); blockExecutor.ExecuteBlock(executionBlock, liveDatabase.ConnectionProperties.ServerName, liveDatabase.ConnectionProperties.DatabaseName, liveDatabase.ConnectionProperties.IntegratedSecurity, liveDatabase.ConnectionProperties.UserName, liveDatabase.ConnectionProperties.Password);
When run this line "work.BuildFromDifferences(differences, Options.None, false);" throws the null reference exception.
Here's the stack trace:
at RedGate.SQLCompare.Engine.Dependencies.OrderedList(IDictionary workitems) at _32._1(Dependencies , Boolean ) at RedGate.SQLCompare.Engine.Work._1(ExecutionBlock , Options , Database , Database , _29 ) at RedGate.SQLCompare.Engine.Work.GenerateSql(Differences differences, Difference onlyDifferenceToInclude, Options options, Boolean runOnTwo) at RedGate.SQLCompare.Engine.Work.BuildFromDifferences(Differences differences, Difference onlyDifferenceToInclude, Options options, Boolean runOnTwo) at RedGate.SQLCompare.Engine.Work.BuildFromDifferences(Differences differences, Options options, Boolean runOnTwo)
Any thoughts?
Comments
It looks like you are using the RegisterForDataCompare method to load the live database. For SQL Compare schema comparisons you need to use the standard Register method instead, and supply the options you are using here too. Something like this:
Hope this helps.
Regards,
Jonathan
-Project Manager
-Red Gate Software Ltd
Not sure how that slipped in X(
Well spotted and many thanks