Unable to open the physical file Operating system error 32

Well this i did the below to get the error, don’t have a clue why the database connection fails.

  1. Create a new ASP.NET Website
  2. Add a new *.mdf database to App_Data
  3. Add some tables to it using Server Explorer in Visual Studio
  4. Right click DataBase and Copy Connection string. Insert it into WebConfig File like below
        <add name="DB" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=C:inetpubwwwrootgsApp_Datadb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
  5. Add some code to get the data from
    selectStatement = "select * from users";
    SqlDataAdapter da = new SqlDataAdapter(selectStatement,
    DataTable dtUsers = new DataTable();
    GridView1.DataSource = dtUsers.DefaultView;

and zoot you get the error


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I have a sneaky suspicion it has to do with permissions. Give full control to your “Authenticated Users”.

In case you are wondering how to do this — I am on Windows 7 and the steps go like this:

  • Right-click on the MDF file and click properties.
  • Select the “Security” tab and select your “Authenticated Users” (or
    something that looks right).
  • Click “Edit” and select the “Allow” check-box for “Full Control”.
  • OK all the way out.


Method 2

The top result from Google seems to address your question:

Just in case if anybody is still looking for solution to this error, this works for me:

1) Open the VStudio project for which
you need to connect to a SQL database

2)Separately, Go to

3) Look for
SQL Server (SQLEXPRESS) service and
Stop it

4) Start it again

5) Try
connecting your database now.

Looks like the reason it works has
something to do with User Instance
discussion that is going on in this

Method 3

I was struggling with this error to and I found that the error was in the database instance that was online so I took it offline from SQLserver management studio,I’ve shared the steps followed and the solution HERE

Method 4

In my case, I had the database in instance MSSQLSERVER while trying to attach it to SQLEXPRESS. Dropping from the first instance freed the file.

Method 5

About error: Operating system error 32, Open error …

First off all, give permission to mdf file. In my case NETWORK SERVICE account have FULL ACCESS on data.mdf.

Well, my workspace:

  1. SSMS have attached data.mdf
  2. In same time in VS2010 I have open solution with same database file: data.mdf, but can not make successfully connection.

Solution: in CONNECTION PROPERTIES on USER INSTANCE change TRUE to FALSE and refresh connection inside VS on this database.
Finaly, no more opening error and you have access on same database file in same time from SSMS and VS2010.

Connection string example:

DataSource=.SQLEXPRESS;AttachDbFilename=D:ContractsApp_Datadata.mdf;Integrated Security=True;User Instance=False



All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x