Jeremy Wadsworth
My Contribution to the ASP.NET Community


Welcome   
Welcome to my personal website. Here you will find blog posts related to web development as well as personal related interests. If you're here for the source code to my Personal Web Site Kit, please register and you'll receive an email when your account has been approved.


Latest Blog Entries

 Saturday, August 02, 2008


Unable to open the physical file \App_Data\DevResource.mdf. Operating system error 5: 5(Access is denied.).    
Here is the exact error I received.

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

After a little Googling something I read pointed me in the right direction. I imagine there are many scenarios that could trigger this error. In my case, I had restored a backup file into the App_Data folder of my website, setup the web.config, and tried to run. The issue was that when I restored the database backup file, the MDF file created in my App_Data folder, didn't have any file permissions on it. So I gave asp.net account rights and everything worked fine.


jeremy at 9:35 PM | (10) Comments | Add a comment | Permalink





Commments
Tariq AlFarsi said...

I faced same problem, also i goggled a lot but most of answers are not clear or difficult to understand ,, lets make it easy .. 1- Go Visual Studio Developer 2005 or 2008 2- Right Click on the DatabaseFile.mdf then choose properties. 3- Change the userInstance from True to False .. your done ..

Thursday, November 27, 2008 3:50 PM

Rinaldi said...

Tariq is there anyway to do it through the SQL Server Management Studio or through the web.config? Thank you very much.

Wednesday, December 23, 2009 3:43 PM

http://www.gratiscasinogames.com/ said...

Recently I upgraded my development machine to Windows 7 and moved all daatabase files to it as well. When I tried to attach one of the database to SQL Server 2008, i got the following error. Unable to open the physical file. Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error: 5120)

Friday, May 07, 2010 9:45 PM

Tiffany jewellery said...

Tariq is there anyway to do it through the SQL Server Management Studio or through the web.config? Thank you very much.

Friday, July 16, 2010 9:05 PM

bad credit auto loan said...

I tried the way and thanks for the shortcut, and CTRL SHIFT U is working fine but CTRL SHIFT L is not working for me to change the cases to lower case, it simply removes the whole line in query analyzer.

Tuesday, July 20, 2010 10:45 AM

Manolo Blahnik Shoes said...

It is good to see you verbalise from the heart and your clarity on this important subject can be easily observed. Thanks again!

Sunday, August 15, 2010 1:05 AM

mbt shoes clearance said...

I read your article.The things you have written sound very sincere and nice topics i am looking forward to its continuation.

Thursday, August 19, 2010 4:33 AM

china wholesale said...

<a href="http://www.pandawill.com/">cell phones</a>, <a href="http://www.pandawill.com/">touch screen</a>, <a href="http://www.pandawill.com/">china phones online</a>,

Thursday, August 26, 2010 3:37 AM

best british casinos said...

Your problem is you are sending SQL Server to look for it's LDF and MDF files in IIS root folder well it will not work. Script the database and remove the reference to IIS root folder and execute it in your machine get it to work then move it to the production server. SQL Server and IIS are only connected by connection string. Hope this helps.

Saturday, August 28, 2010 7:16 AM

wholesale nfl jerseys said...

Hey guys, I hope this allowed, I have never used this website before so I wasn't really sure what this was going to do. <a href="http://www.nfljerseyse.com" title="wholesale nfl jerseys">wholesale nfl jerseys</a> So this is just a test post. I really like this forum, it has some excellent discussions that take place.

Wednesday, September 01, 2010 11:54 PM

  Leave a comment

Enter Your Name:
 
Enter your website
Security code from image below:  
Need Custom Controls Work or Training?
   


Join WebHost4Life.com






If you would like to help support this project, please click the button below to make a small donation.