Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I saved my (mydatabase.mdf) file in D drive inside database folder. I have provide connection by app.config file in visual studio 2010. When I am running my windows application it shows following error.

Unable to open the physical file "D:\database\mydatabase.mdf". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file D:\database\mydatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I am trying following connection string

What I have tried:


<configuration>
<connectionstrings>
<add name="newConnectionString">
connectionString="Data Source=.;AttachDbFilename=D:\database\mydatabase.mdf;integrated Security =True"
providerName="System.Data.SqlClient"/>

Posted
Comments
RickZeeland 30-Mar-16 5:45am    
Did you detach the original database first ?
Did you attach the copied database ?

See this "bad habits" article:
http://blogs.sqlsentry.com/aaronbertrand/bad-habits-attachdbfilename/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900