Access Database Locking Problem

  • Thread starter Red Dog via .NET 247
  • Start date
R

Red Dog via .NET 247

Hi all,

I need to read data from an Access Database that has been deployed onto a CD. This obviously makes both the MDB and the containing folder read only. I've set the connection to be read-only but for some reason I get a locking issue.

The error is:
System.Data.OleDb.OleDbException: Could not lock file.
at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Where the connection string is as follows:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\Northwind.mdb;User ID=Admin;Password=;Extended Properties=;Mode=Read;

Please help me! I'm hoping is just requiring the use of some special connection string property...

Andrew Weaver
www.ssw.com.au
 
P

Paul Sullivan

When you open an Access database, It has to write a locking file to
the directory where the DB lives. If it lives on plastic, your out of
luck. To test this - make a folder on your desktop and drag a copy of
the DB into it. Open that DB and then peek into the folder - you will
see a .ldb file. Close the db and it disappears. Now you see the
problem with the DB on read-only plastic.

Paul Sullivan
 
P

Paul Clement

¤ Hi all,
¤
¤ I need to read data from an Access Database that has been deployed onto a CD. This obviously makes both the MDB and the containing folder read only. I've set the connection to be read-only but for some reason I get a locking issue.
¤
¤ The error is:
¤ System.Data.OleDb.OleDbException: Could not lock file.
¤ at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
¤ at System.Data.OleDb.OleDbConnection.InitializeProvider()
¤ at System.Data.OleDb.OleDbConnection.Open()
¤ at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
¤ at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
¤ at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
¤ at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
¤
¤ Where the connection string is as follows:
¤ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\Northwind.mdb;User ID=Admin;Password=;Extended Properties=;Mode=Read;
¤
¤ Please help me! I'm hoping is just requiring the use of some special connection string property...
¤
¤ Andrew Weaver
¤ www.ssw.com.au
¤
¤ -----------------------
¤ Posted by a user from .NET 247 (http://www.dotnet247.com/)
¤
¤ <Id>r5tMbE9xCU2lUfXvdmyAhw==</Id>

Try changing the Mode argument to the following:

Mode=Share Deny Write

This should prevent the Jet database engine from attempting to create the corresponding .LDB file.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top