Solved

OleDbConnection Database locking issues

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Advice in Xamarin 21 97
Help Required 3 108
Identify two keyboard codes and how to enter them 9 56
storing csv file in table variable in Python 2 27
This article will show, step by step, how to integrate R code into a R Sweave document
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.
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…

832 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