Red Gate forums :: View topic - Registration fails because db has the same name
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

Registration fails because db has the same name

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



Joined: 02 Dec 2007
Posts: 7

PostPosted: Wed Feb 06, 2008 11:34 am    Post subject: Registration fails because db has the same name Reply with quote

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?
Back to top
View user's profile Send private message
Michelle Taylor



Joined: 30 Oct 2006
Posts: 529
Location: Red Gate Software

PostPosted: Thu Feb 07, 2008 4:51 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
jprice2269



Joined: 02 Dec 2007
Posts: 7

PostPosted: Thu Feb 14, 2008 12:42 am    Post subject: A walkthrough Reply with quote

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?
Back to top
View user's profile Send private message
Michelle Taylor



Joined: 30 Oct 2006
Posts: 529
Location: Red Gate Software

PostPosted: Thu Feb 14, 2008 12:46 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
jprice2269



Joined: 02 Dec 2007
Posts: 7

PostPosted: Thu Feb 14, 2008 2:46 pm    Post subject: Reply with quote

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

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

This doesnt work either.
Back to top
View user's profile Send private message
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