Link to home
Start Free TrialLog in
Avatar of cycledude
cycledudeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

C# and MS Access problem

Hi

I am developing a c# 2010 winforms application connecting to a networked MS Access 2003 database.

Occasionally I am seeing a message

"the database has been placed in a state by user 'admin' on machine 'ABCD'"

this doesn't happen too often and when it does, if I close the application and re-open it, it usually works ok.


The database is password protected and to my knowledge, I am the only person who knows it... the error appears when I have not got access open... so I can't see why there is a lock going on?  None of the code allows users to modify the database structure, only the contents...

What should I look for?
Avatar of Kishan Zunjare
Kishan Zunjare
Flag of Australia image

It sounds like Access thinks something in the database is open in design mode.  it must be something outside the database in the registry.
Avatar of Scott McDaniel (EE MVE )
This can occur due to a "hanging lock file". When an access database is opened by any method (including your C# program), Access creates a "lock file", generally in the same directory where the database file is located. That file is named the same as the database, but with a .ldb (2003 or older) or .accdb (2007 or newer) extension. Sometimes that lockfile is not removed when the database is closed, and the next time it's opened Access will think someone else has the file open, and you can receive that message.

Be sure that you always properly close all connections to the database, and be sure users have read/write/create/delete permissions on the folder hosting that database.

Your database may also be corrupt. The easiest way to fix that is to create a new, blank database in Microsoft Access and import everything into that new database. Depending on your version of Access, the steps to do that are different, so if you're not clear on how to do that post back and we'll give you further guidance.
Avatar of cycledude

ASKER

Thanks for the comments

I do try to be vigilant about closing the datareader after accessing the database, I may have missed one or 2 connections, can't be sure... but I had issues in the past where I hadn't close the datareader and it threw odd application errors, so since then I have tried to ensure the database datareader is closed...
ASKER CERTIFIED SOLUTION
Avatar of cycledude
cycledude
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the problem appears to have ceased since implementing this solution.