Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 27, 2009 09:32 PM by gerrylowry
Jan 09, 2007 02:31 AM|LINK
I have a file system project that I moved from the VS Web server to IIS now it will not run; I receive the following message:
An attempt to attach an auto-named database for file C:\Documents and Settings\Server\My Documents\Visual Studio 2005\WebSites\MyProject\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located
on UNC share.
The file is in the App_Data folder of my project, and it is the only one on the system.
Does anyone know where this database keeps its connection string? It is not in my web config file.
Any help is appreciated.
Jan 09, 2007 04:20 AM|LINK
Go to IIS->your Virtual Directory or website->right click->Properties->ASP.NET tab->Edit configuration. There you can see all your connection strings.
Regarding the error message, make sure that App_Data folder is readable/writable by the ASPNET user. Right click the folder, go to securities and give permissions to the ASPNET user.
Jan 09, 2007 01:59 PM|LINK
This is the exception I get when my app tries to run:
An attempt to attach an auto-named database for file C:\Documents and Settings\MyServer\My Documents\Visual Studio 2005\WebSites\MyApplication\App_Data\aspnetdb.mdf failed. A database with the same name exists,
or specified file cannot be opened, or it is located on UNC share.
Also I looked at the connection manager and this is what I found:
LocalSQLServer: data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
What is meant by LocalSqlServer?
My database is also listed, however, it has the connection string that is in my web config file.
Should the aspnetdb be listed in my web config also?
Jan 09, 2007 05:54 PM|LINK
LocalSqlServer is the default built in connection string to be used by the ASPNET runtime while creating the default DB (aspnetdb.mdf) at runtime to be used by the membership API. If you dont want to use the membeship API, or want to use your own DB for
it, then you can remove this connection string by either deleting this entry or by adding a <remove> tag in your web.config before the conenction strings section.
Check this blog for details:
Hope this helps,
Jan 09, 2007 06:09 PM|LINK
I want to use my aspnetdb, my problem is that I get the error message I posted earlier so I was just thinking it has something to do with the connection string.
Does anyone have any suggestions as to why I get the message?
I have no other aspnetdb.mdf files in the project.
It runs fine if I switch over to the ASP.NET Developer Server.
I appreciate any help on this!!!!
Jan 09, 2007 06:21 PM|LINK
Did you give read/write permissions to the app_data folder as I mentioned earlier? Please check the last section of this article for the details on the same:
Jan 09, 2007 06:36 PM|LINK
Jan 09, 2007 07:01 PM|LINK
Check out this blog I wrote sometime back:
Jan 09, 2007 07:49 PM|LINK
First I should say that I really apreciate your help!
I made the changes from your blog, still getting the same message.
This is so frustrating!!!
I looked and my virtual directory is not in the Inetpub\wwwroot\, does make a difference for how we are trying to do things here?
I created a virtual directory from IIS and it does show in the IIS manager.
Just reaching for straws now.
I appreciate any thoughts or suggestions.
Jan 10, 2007 05:23 AM|LINK
Virtual directory should not make a difference. Also you need not put your project in Inetpub/wwwroot.
Try giving read/write permissions to everyone on the App_Data folder for the time being. If that too does not work, then check if your SQL Server 2005 Express is running or not and the connection string is configured properly. I hope you have SQL server
express installed and not SQL server 2005.