How can we help you today? How can we help you today?
lc6529
After a lot of digging, I came up with this code, however oRedGateSession.TableDifferences.Count always returns 0 even if I delete all records from one of my tables. If I run the command line SQLDATACOMPARE /SYNC /PROJECT:"C:\Sync_Labelvision_Master.SDC" Which uses the SAME project...the tables are synced. How can I get the code to work? Sub SyncDatabases(ByVal sServerName As String) ' ' Copied From Synchronizing,Data Example In Help File ' Dim objProject As RedGate.SQLDataCompare.Engine.Project = RedGate.SQLDataCompare.Engine.Project.LoadFromDisk("C:\Sync_Labelvision_Master.SDC") ' ' Set Up Our Databases ' Dim dbMaster As New Database Dim dbTarget As New Database Dim tblMappings As New TableMappings Dim oLivedb As LiveDatabaseSource ' ' Register First DB For Comparison ' oLivedb = DirectCast(objProject.DataSource1, LiveDatabaseSource) dbMaster.RegisterForDataCompare(oLivedb.ToConnectionProperties()) ' ' Register Second DB For Comparison ' oLivedb = DirectCast(objProject.DataSource2, LiveDatabaseSource) dbTarget.RegisterForDataCompare(oLivedb.ToConnectionProperties()) tblMappings.Options = objProject.Options tblMappings.CreateMappings(dbMaster.Tables, dbTarget.Tables) Try Dim oRedGateSession As New ComparisonSession oRedGateSession.Options = objProject.Options oRedGateSession.CompareDatabases(dbMaster, dbTarget, tblMappings, SessionSettings.Default) If oRedGateSession.TableDifferences.Count > 0 Then Dim oProvider As New SqlProvider Dim oExBlock As ExecutionBlock oExBlock = oProvider.GetMigrationSQL(oRedGateSession, True) Dim stream As IO.FileStream = oExBlock.GetFileStream() Dim oBExecutor As RedGate.SQL.Shared.BlockExecutor = New BlockExecutor oBExecutor.ExecuteBlock(oExBlock, sServerName, "labelvision_master", True, "lvadmin", "lvadmin") oExBlock = oProvider.Block If (TypeOf oExBlock Is ExecutionBlock) Then oExBlock.Dispose() End If oRedGateSession.Dispose() Catch ex As Exception MsgBox(ex.Message) Finally End Try ' ' dispose of the objects to delete temporary files ' dbMaster.Dispose() dbTarget.Dispose() End Sub / comments
After a lot of digging, I came up with this code, however oRedGateSession.TableDifferences.Count always returns 0 even if I delete all records from one of my tables. If I run the command line SQLD...
0 votes