Solved

OleDbConnection Database locking issues

Posted on 2004-08-26
2
486 Views
Last Modified: 2008-02-01
Hi,

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";

conn.Open();

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

Thanks.

0
Comment
Question by:ba272
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 11909916
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.

0
 
LVL 5

Expert Comment

by:rsriprac
ID: 11918812
You need a:

Mode=Share Deny None;

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

-Ram
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question