Solved

OleDbConnection Database locking issues

Posted on 2004-08-26
2
482 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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now