Registration fails because db has the same name

Forum for users of SQL Toolkit 3,4,and 5

Registration fails because db has the same name

Postby jprice2269 » Wed Feb 06, 2008 11:34 am

I have a database, which has been detached from the server, the files copied and then reattached.

The database on the server moves on in terms of structure.

Now, I need to compare the database on the server with the copy I got earlier.

I can register the current database, setting Database name as 'Source' no problem.

Toolkit wont let me attach (as an sqlexpress) the copy database, even setting Database name as 'Destination'. (will do if I do this first, but then the other fails)

Says cant attach as the database name is the same (the original name stored in the file) and appears to ignore the Database Name property.

Ideas?
jprice2269
 
Posts: 7
Joined: Sun Dec 02, 2007 4:52 pm

Postby Michelle Taylor » Thu Feb 07, 2008 4:51 pm

I don't quite follow what you're trying to do - could you give an example of the code you're using to attach (register?) the second database?
Michelle Taylor
 
Posts: 529
Joined: Mon Oct 30, 2006 12:45 pm
Location: Red Gate Software

A walkthrough

Postby jprice2269 » Thu Feb 14, 2008 12:42 am

Start with a database file, FileName File1.mdf,

Copy the file and call it File2.mdf.

Both files are identical right now,


File1.mdf is opened and is changed in some way,.


Now the task is to determine the changes between File1 and File2

Firstly need to register the two files.

So,

Register File1

_combinedServerName = \"Server=.\\SQLEXPRESS; AttachDBFileName=File1.mdf; Database='Source'; User instance=true; pooling=false;\"

databaseName = \"Source\"

_connectionProperties = New Engine.ConnectionProperties(_combinedServerName, databaseName)

_connectionProperties.IntegratedSecurity = True

m_db1.Register(_connectionProperties, m_engineOptions)

This suceeds.


Register File2

_combinedServerName = \"Server=.\\SQLEXPRESS; AttachDBFileName=File2.mdf; Database='Dest'; User instance=true; pooling=false;\"

databaseName = \"Dest\"

_connectionProperties = New Engine.ConnectionProperties(_combinedServerName, databaseName)

_connectionProperties.IntegratedSecurity = True

m_db2.Register(_connectionProperties, m_engineOptions)



This fails with the error message

Database 'FILE1.MDF' already exists. Choose a different database name.
Cannot attach the file 'FILE2.MDF' as database 'Dest'.

It is accessing the correct file (file2.mdf) but reading its internal name and not the given name Dest.

Any ideas?
jprice2269
 
Posts: 7
Joined: Sun Dec 02, 2007 4:52 pm

Postby Michelle Taylor » Thu Feb 14, 2008 12:46 pm

I think it's quite likely we don't support that kind of connection string - we don't support any of the special SQLEXPRESS connection strings, only straightforwards connections to live databases.
Michelle Taylor
 
Posts: 529
Joined: Mon Oct 30, 2006 12:45 pm
Location: Red Gate Software

Postby jprice2269 » Thu Feb 14, 2008 2:46 pm

But you do allow to specify a database name in your connectionProperties.

e.g.New Engine.ConnectionProperties(_combinedServerName, databaseName)

This doesnt work either.
jprice2269
 
Posts: 7
Joined: Sun Dec 02, 2007 4:52 pm


Return to SQL Toolkit Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests