|
-
Mar 17th, 2010, 11:00 AM
#1
Thread Starter
Addicted Member
Connection String Issue
I am getting this error:
{"An attempt to attach an auto-named database for file D:\WORK\DocStore\DocStore\Database\DocStore.mdf\ failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."}
I verified the file exists and is checked out for edit.
This is in my app.config:
Code:
<connectionStrings>
<add name="DocStoreEntities" connectionString="metadata=res://*/Database.DocStore.csdl|res://*/Database.DocStore.ssdl|res://*/Database.DocStore.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|;Integrated Security=True;Connect Timeout=30;User Instance=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
<add name="DocStore.My.MySettings.DocStoreConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
I am populating the DataDirectory like this:
My.Settings.DatabaseLocation = "D:\WORK\DocStore\DocStore\Database\DocStore.mdf"
AppDomain.CurrentDomain.SetData("DataDirectory", My.Settings.DatabaseLocation)
Is it due to the "/" at the end of my .mdf\ ?
If it is, where is it coming from?
Any help would be greatly appreciated!
Thanks,
Eroc
-
Mar 17th, 2010, 05:56 PM
#2
Thread Starter
Addicted Member
Re: Connection String Issue
I tried removing the | but I take it that is what declares its a variable.
Anyone have any ideas?
-
Mar 17th, 2010, 06:55 PM
#3
Re: Connection String Issue
That indicates that the database can't be attached because a database with that name is already attached. It's likely that the database wasn't detached properly last time you ran the app. Try deleting the entire bin folder, which might require you to close VS first. If it won't delete then the database is still attached, so you might need to restart SQL Server. I know I had similar issues some time ago but I can't recall whether it righted itself or I had to do something specific.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|