• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 509
  • Last Modified:

OleDbConnection Database locking issues


I'm tring to give my C# program read only access to an MDF file stored on a remote drive, which is getting written to by another process on the remote machine.  When my code reaches the Open() call, it throws an exception.  The drive is a read-only drive.

The code I use is:

OleDbConnection conn = new OleDbConnection();

conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +@"Data source=" + "Y:\history.mdb";


The exception says that the file is already in use.  What could be wrong?  Any ideas about what I could try?


1 Solution
Well the error is not because of read-only attribute,
the access file is getting exclusively locked by your other process which is writing it. Open it in shared mode there so that you can open for read here.

You need a:

Mode=Share Deny None;

in your connection string so it will not exculsivly lock you access database file.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now