Comments
Sort by recent activity
Ok, really works!
Adding this:
Dim mappings As New TableMappings
'-It´s is new
mappings.CreateMappings(db1.Tables, db2.Tables)
Dim cant, hay As Integer
hay = mappings.Count
For cant = hay - 1 To 0 Step -1
mappings.RemoveAt(cant)
Next
'
...
tableMapping.FieldMappings.Add(New FieldMapping(tableMapping.Obj1.Fields("myField1"), tableMapping.Obj2.Fields("myField2"), FieldMappingStatus.Success))
'----and adding this
tableMapping.MatchingMappings.Clear()
tableMapping.MatchingMappings.Add(tableMapping.FieldMappings("myField1"))
I get a Status = Success.
Regards,
Jorge Bravo / comments
Ok, really works!
Adding this:
Dim mappings As New TableMappings
'-It´s is new
mappings.CreateMappings(db1.Tables, db2.Tables)
Dim cant, hay As Integer
hay = mappings.Count
For cant = hay - 1 To 0...
Before tableMapping.RefreshMappingStatus() and after I get status: UnableToCompare.
I continue trying... / comments
Before tableMapping.RefreshMappingStatus() and after I get status: UnableToCompare.
I continue trying...
You´re right, Brian.
I my past test I get a Status=UnableToCompare but, modifying code and including CreateMappings and unmapping all works well.
Now, I tested my code commenting those lines (without CreateMappings...) and code works very fine.
I don´t know... maybe I have a trouble in my machine...
Really your code works fine!
Regards,
Jorge Bravo / comments
You´re right, Brian.
I my past test I get a Status=UnableToCompare but, modifying code and including CreateMappings and unmapping all works well.
Now, I tested my code commenting those lines (witho...
Thanks, Brian.
I´m testing but dont works.
I have two tables with same structure but the first have two rows and second, three: script don´t make nothing.
My code is this:
Dim db1 As New Database
Dim db2 As New Database
db1.RegisterForDataCompare(New ConnectionProperties(MyServer1, MyDB1, myAccount1, myPass1), Options.Default)
db2.RegisterForDataCompare(New ConnectionProperties(MyServer2, MyDB2, myAccount2, myPass2), Options.Default)
Dim mappings As New TableMappings
Dim tableMapping As TableMapping = CType(mappings.Join(db1.Tables("[dbo].[foo]"), db2.Tables("[dbo].[bar]")), TableMapping)
tableMapping.FieldMappings.Add(New FieldMapping(tableMapping.Obj1.Fields("WidgetID"), tableMapping.Obj2.Fields("WidgetID"), FieldMappingStatus.Success))
tableMapping.RefreshMappingStatus()
mappings.Add(tableMapping)
Dim session As New ComparisonSession
session.CompareDatabases(db1, db2, mappings)
Dim provider As New SqlProvider
Dim block As ExecutionBlock
Try
block = provider.GetMigrationSQL(session, True)
Dim executor As RedGate.SQL.Shared.BlockExecutor = New BlockExecutor
executor.ExecuteBlock(block, MyServer2, MyDB2, False, myAccount2, myPass2)
Catch ex As SystemException
Dim err As String
err = "Error: " & ex.Message
Finally
block = provider.Block
If (TypeOf block Is ExecutionBlock) Then
block.Dispose()
End If
End Try
session.Dispose()
db1.Dispose()
db2.Dispose() / comments
Thanks, Brian.
I´m testing but dont works.
I have two tables with same structure but the first have two rows and second, three: script don´t make nothing.
My code is this:
Dim db1 As New Database
D...
It´s clear, Brian. But don´t works.
My code is like:
Dim db1 As New Database
Dim db2 As New Database
db1.RegisterForDataCompare(New ConnectionProperties(MyServer1, MyDB1, myAccount1, myPass1), Options.Default)
db2.RegisterForDataCompare(New ConnectionProperties(MyServer2, MyDB2, myAccount2, myPass2), Options.Default)
Dim mappings As New TableMappings
Dim tableMapping As TableMapping = CType(mappings.Join(db1.Tables("[dbo].[myTable1]"), db2.Tables("[dbo].[myTable2]")), TableMapping)
tableMapping.FieldMappings.Add(New FieldMapping(tableMapping.Obj1.Fields("myField1"), tableMapping.Obj2.Fields("myField2"), FieldMappingStatus.Success))
tableMapping.RefreshMappingStatus()
mappings.Add(tableMapping)
Dim session As New ComparisonSession
session.CompareDatabases(db1, db2, mappings)
Dim provider As New SqlProvider
Dim block As ExecutionBlock
Try
block = provider.GetMigrationSQL(session, True)
Dim executor As RedGate.SQL.Shared.BlockExecutor = New BlockExecutor
executor.ExecuteBlock(block, MyServer2, MyDB2, False, myAccount2, myPass2)
Catch ex As SystemException
Dim err As String
err = "Error: " & ex.Message
Finally
block = provider.Block
If (TypeOf block Is ExecutionBlock) Then
block.Dispose()
End If
End Try
session.Dispose()
db1.Dispose()
db2.Dispose()
This is your code translated to VB.NET and don´t works to me.
Regards,
Jorge / comments
It´s clear, Brian. But don´t works.
My code is like:
Dim db1 As New Database
Dim db2 As New Database
db1.RegisterForDataCompare(New ConnectionProperties(MyServer1, MyDB1, myAccount1, myPass1), Opt...