| Author |
Message |
jprice2269
Joined: 02 Dec 2007 Posts: 7
|
Posted: Wed Feb 06, 2008 11:34 am Post subject: Registration fails because db has the same name |
|
|
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 |
|
 |
Michelle Taylor
Joined: 30 Oct 2006 Posts: 522 Location: Red Gate Software
|
Posted: Thu Feb 07, 2008 4:51 pm Post subject: |
|
|
| 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 |
|
 |
jprice2269
Joined: 02 Dec 2007 Posts: 7
|
Posted: Thu Feb 14, 2008 12:42 am Post subject: A walkthrough |
|
|
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 |
|
 |
Michelle Taylor
Joined: 30 Oct 2006 Posts: 522 Location: Red Gate Software
|
Posted: Thu Feb 14, 2008 12:46 pm Post subject: |
|
|
| 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 |
|
 |
jprice2269
Joined: 02 Dec 2007 Posts: 7
|
Posted: Thu Feb 14, 2008 2:46 pm Post subject: |
|
|
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 |
|
 |
|
|
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