OleDbException: Could not update; currently locked

  • Thread starter Thread starter Luke Neumann
  • Start date Start date
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
 
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.
 
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.
 
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.
 
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
 
Back
Top