What is Original DB Name when attaching db
Posted on 2003-12-03
We have an application that operates on a named instance of MSDE. In the instance there can be 1 -> many databases all with a standard structure.
Anyway, when we ship a new database the MDF is sent on CD, the application then copies this to a specifed location and attaches it. Hey presto...
However the snag is that we need to be able to attach the database as the original name of the database, simple enough however, on top of this requirement we need to effectively have the ability to display the original name of the database in an "Attach Database" dialog box (kind of like a file browser dialog which displays the original db name kind of like this:
Please select database to attach:
I am sure that somehow retrievable from unattached MDF since in EM when you select a file to attach it displays the original db name as default in the dialog box. We dont want to resort to shipping and further files containing this info as that will lead to other problems.
One dirty option we have which we will take if we have no other alternative to is to open the file in a binary stream and append to the end the name, then strip this off before attaching.
Any help would be appreciated.