I’ve had some problems connecting with my database in a web application. The database is a .mdf and sits in my App_Data Folder. I’m using IIS 7.5 to run and debug my website.
I got following error:
Troubleshoot Error: An attempt to
attach an auto-named database for file
database location failed. A
database with the same name exists, or
specified file cannot be opened, or it
is located on UNC share.
I came up with this solution:
BUT this involves leaving my computer’s login and password wide open in the web.config. As you may understand, I’m not too happy about that… Is there a way to hide my password from the web.config or solve this problem otherwise? Thanks.
Assuming your storing it in connection strings – since ASP.NET 2.0, you can encrypt any section…
run from your site root..
G:\content\snippet-site>C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pef “connectionStrings”
This should do the trick.
A bit more info…
http://weblogs.asp.net/scottgu/archive/2006/01/09/434893.aspx