OleDbException: Could not update; currently locked

L

Luke Neumann

Hello,

I have a standalone windows application that uses MS Jet 4.0 to read
and write from MS Access database.

Rather randomly, I keep getting this exception:

System.Data.OleDb.OleDbException: Could not update; currently locked.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr) at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) at
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at
AccessDataInterface.AccessItemStore.SaveItem(OutlookItem item, Int32
attemptNumber)

I tried to protect the ExecuteNonQuery method using Mutex class to
ensure that only one thread can execute this at the same time, but it
didn't help.

Any ideas?

Thanks
Lukas Neumann
 
J

Jim Hughes

Is there any chance that the database is being opened by another
application? Maybe Access?

If you use Access in design mode on a mdb file it will open in exclusive
mode.
 
L

Luke Neumann

No, the MDB file is created and used excusively by the application.
Only thing that I can think of is maybe some Antivirus software, but it
shouldn't cause Access to lock the database.
 
G

Guest

Could part of your routine open the table and then stumble but try to
continue on.

This happened to me recently so I had to add code to close and reopen my
table in case part of my routine failed.

Just a thought.
 
L

Luke Neumann

Yes, that what I did too - it just tries again after a while. But it is
not solution of the problem, it just hides it. I'd like at least like
to know what is cause of this error...

Lukas
 

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