A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
Error In Sql Server
Unable to open the physical file "C:\inetpub\wwwroot\BknSample\App_Data\BknIIS.mdf". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file C:\inetpub\wwwroot\BknSample\App_Data\BknIIS.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Solution :
Here is Permanent Solution of this Problem:
Point 1:
Make sure U have Database.mdf file under app_data directory if you are using |DataDirectory| in the Connection String.
Point 2:
string connstring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
I hope this will solve your Problem.
Point 1:
Make sure U have Database.mdf file under app_data directory if you are using |DataDirectory| in the Connection String.
Point 2:
string connstring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
I hope this will solve your Problem.
Comments
Post a Comment