Solved

OleDbConnection Database locking issues

Posted on 2004-08-26
2
484 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Program to display an alert on Windows Toolbar 2 79
parse convert xml feed to text (python) 2 83
Java Loop 6 61
Help Required 3 97
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

777 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