Red Gate forums :: View topic - Compare BACKUP to Live and Change MatchingMappings
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Toolkit Previous Versions
SQL Toolkit Previous Versions forum

Compare BACKUP to Live and Change MatchingMappings

Search in SQL Toolkit Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
rockywurden



Joined: 10 Dec 2007
Posts: 6

PostPosted: Thu Jan 31, 2008 7:18 pm    Post subject: Compare BACKUP to Live and Change MatchingMappings Reply with quote

Problem: How do you change the MatchingMappings on a table when 1 of the databases is a SQL BACKUP.

Table3 has primary key RECID
Need to change to ROWGUID which has a unique index

map.MatchingMappings.clear
map.MatchingMappings.ADD("ROWGUID")
'Throws the following error.
*****Mappings only supports mapping objects. Parameter name: value

Thanks
Rocky

Following Code Sample see CASE TABLE3 Statement.

Dim db1 As New BackupDatabase
Dim db2 As New Database

Try
db1.RegisterForDataCompare(New String() {sFile}, Nothing)
db2.RegisterForDataCompare(New ConnectionProperties(tServer, tdatabase))
Dim mappings As New SchemaMappings
Dim map As TableMapping
mappings.CreateMappings(db1, db2)

'Exclude tables and change Index
For Each map In mappings.TableMappings
Select Case map.Obj1.Name.ToUpper
case "TABLE2"
map.Include = False
Case "TABLE3"
'This table Matching field is RECID and is the primary key.
'Need to change field to ROWGUID which has a unique index.
map.MatchingMappings.clear
map.MatchingMappings.ADD("ROWGUID")
'Throws the following error.
*****Mappings only supports mapping objects. Parameter name: value

End Select
Next map

Dim session As New ComparisonSession()
session.CompareDatabases(db1, db2, mappings)
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 395
Location: Red Gate Software Ltd

PostPosted: Fri Feb 01, 2008 9:40 am    Post subject: Reply with quote

If you get the sample projects available from the reference help here...

http://help.red-gate.com/help/SQLDataCompareAPIv6/1/en/index.htm

In the TableMappingExample.cs there's a full example of changing the fields to be compared. Although as you're comparing to a backup you can only use indexes and not custom comparison keys. The call you're interested in is TableMapping.UseIndexForMapping

HTH
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group