G
Glen Buell
Hi all,
I have a major problem with my ASP.NET website and it's SQL Server
2005 Express database, and I'm wondering if anyone could help me out
with it.
This site is on a webhost (WebHost4Life) and was running fine and
dandy, until I decided I needed to add some additional stored
procedures to the database.
I made these changes locally, and uploaded the changed files, which
included the .MDF file for the database, overwriting the files that
were on my host. I did not upload the .LDF file (and WebHost4Life say
not to, since you can get errors like "database already exists for
this user), and now my website is broken.
I'm getting an error that my primary database file does not match my
log file. I have attempted to delete both the .MDF and .LDF files,
hoping to reload, but they're locked, and cannot be deleted or
renamed.
I believe the "lock" on these files is due them being currently
"attached" to the SQLServer Express instance running on my webhost.
I'm led to believe this, since I've tried all kinds of things to get
this to work, including uploading a "copy" of the .MDF file with a
different filename, and attempting to attach a different file (in the
AttachDBFilename section of the connection string) but with the same
"name" attribute. This gave me a different error saying that it could
not attach this new database since one with the same name was already
attached.
My connection string within my web.config file is shown below:
<add name="MyDB" connectionString="data source=.\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|MyDB.mdf;User
Instance=True;Initial Catalog=MyDB"
providerName="System.Data.SqlClient" />
As can be seen by my connection string, I'm using "User Instance=True"
which I thought would create a separate user instance of
SQLServer2005Express, but that this instance exists only for the
lifetime of my .NET web application. Thus, I thought that shutting
down my .NET application, using the "app_offline.htm" trick, that this
would kill my .NET app. instance, which in turn would kill the
SQLServer user instance, thus unlocking my .MDF and .LDF files.
However, this appears not to be the case, as the files (even after
leaving things alone for a few hours, in case of some kind of caching
etc.) are still locked, and cannot be deleted.
Does anyone know of a way for me to unlock these files? I'm thinking
I may have to "detach" the old database somehow, but I can't connect
to it in the first place through my web application, and
unfortunately, since this site is on a remote webhost, I don't have
full access to IIS or the SQLServer service/instances.
Any and all help on this matter is greatly appreciated.
Thanks in advance.
Glen.
I have a major problem with my ASP.NET website and it's SQL Server
2005 Express database, and I'm wondering if anyone could help me out
with it.
This site is on a webhost (WebHost4Life) and was running fine and
dandy, until I decided I needed to add some additional stored
procedures to the database.
I made these changes locally, and uploaded the changed files, which
included the .MDF file for the database, overwriting the files that
were on my host. I did not upload the .LDF file (and WebHost4Life say
not to, since you can get errors like "database already exists for
this user), and now my website is broken.
I'm getting an error that my primary database file does not match my
log file. I have attempted to delete both the .MDF and .LDF files,
hoping to reload, but they're locked, and cannot be deleted or
renamed.
I believe the "lock" on these files is due them being currently
"attached" to the SQLServer Express instance running on my webhost.
I'm led to believe this, since I've tried all kinds of things to get
this to work, including uploading a "copy" of the .MDF file with a
different filename, and attempting to attach a different file (in the
AttachDBFilename section of the connection string) but with the same
"name" attribute. This gave me a different error saying that it could
not attach this new database since one with the same name was already
attached.
My connection string within my web.config file is shown below:
<add name="MyDB" connectionString="data source=.\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|MyDB.mdf;User
Instance=True;Initial Catalog=MyDB"
providerName="System.Data.SqlClient" />
As can be seen by my connection string, I'm using "User Instance=True"
which I thought would create a separate user instance of
SQLServer2005Express, but that this instance exists only for the
lifetime of my .NET web application. Thus, I thought that shutting
down my .NET application, using the "app_offline.htm" trick, that this
would kill my .NET app. instance, which in turn would kill the
SQLServer user instance, thus unlocking my .MDF and .LDF files.
However, this appears not to be the case, as the files (even after
leaving things alone for a few hours, in case of some kind of caching
etc.) are still locked, and cannot be deleted.
Does anyone know of a way for me to unlock these files? I'm thinking
I may have to "detach" the old database somehow, but I can't connect
to it in the first place through my web application, and
unfortunately, since this site is on a remote webhost, I don't have
full access to IIS or the SQLServer service/instances.
Any and all help on this matter is greatly appreciated.
Thanks in advance.
Glen.