Last post Sep 27, 2009 10:32 PM by gerrylowry
Jan 09, 2007 03:31 AM|Jackxxx|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 05:20 AM|vivek_iit|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 02:59 PM|Jackxxx|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 06:54 PM|vivek_iit|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 07:09 PM|Jackxxx|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 07:21 PM|vivek_iit|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 07:36 PM|Jackxxx|LINK
Jan 09, 2007 08:01 PM|vivek_iit|LINK
Check out this blog I wrote sometime back:
Jan 09, 2007 08:49 PM|Jackxxx|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 06:23 AM|vivek_iit|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.
Feb 08, 2007 12:11 PM|chetan.sarode|LINK
Just go to My Computer->Tools->View
then uncheck the last option "Use Simple File Sharing"
Then try it...You will get Security tab.
Sep 20, 2009 04:22 PM|Rehabman|LINK
OK, here ist is sept 2009, and i am haveing the same issue. several days tring to figure out why it works on my vista and xp machine but will not work when published on my host webhostforasp.net.
Did you get it solved and can youshare your results?
Sep 27, 2009 10:32 PM|gerrylowry|LINK
Please define more clearly "the same issue".
If you are deploying by using a hosting service
and your message is still saying
C:\Documents and Settings\Server\My Documents\Visual Studio 2005\WebSites\MyProject\App_Data\aspnetdb.mdf
it follows you will have difficulty.
Your remote path will be different.
If will not likely ever be C:\Documents and Settings\ ...
When I deploy to IIS6, I create a folder like
I publish to my own hard drive first in c:\myasp\myappPublish.
I ftp the files from c:\myasp\myappPublish to c:\xyz\myapp.
(The first c: drive is my local c: drive; the second drive is the servers c: drive.
I run inetmgr, right click ...\Web Sites\Default Web Site\ and choose
New, Virtual Directory... and navigate to c:\xyz\myapp.
It might help you get a useful answer if you could describe your
deployment process with substantial detail.