Why do I get a permission error when connecting to SQL Server from Visual Studio?

Ahmed picture Ahmed · Mar 23, 2013 · Viewed 10.1k times · Source

I have SQL Server 2005 SP4 Express, when I try to establish connection from VS2010 to my database, I get a error:

You don't have permission to open this file

Contact the file owner or an administrator to obtain permission.

I am using windows authentication and I am the only user.

Please help me out to overcome this error.

Also sometimes, it shows file is already open

Answer

FIFO BIZSOL picture FIFO BIZSOL · Jul 17, 2013

First of all close visual studio. Now open visual studio run as administrator. If it not solved your problem then open sql server management studio and follow the steps.

  1. Expand your database.
  2. Right click on your database and choose properties option.
  3. A pop is open, select option menu reside on left side.
  4. Make auto close option true situated in automatic pane.

I am sure your problem is solved now.....

cheers.....