Solved

C# and MS Access problem

Posted on 2014-01-07
5
190 Views
Last Modified: 2014-04-14
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?
0
Comment
Question by:cycledude
  • 3
5 Comments
 
LVL 7

Expert Comment

by:Kishan Zunjare
ID: 39764749
It sounds like Access thinks something in the database is open in design mode.  it must be something outside the database in the registry.
0
 
LVL 84
ID: 39764817
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.
0
 

Author Comment

by:cycledude
ID: 39764847
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...
0
 

Accepted Solution

by:
cycledude earned 0 total points
ID: 39882376
there is a potential solution to this which I got from the microsoft website,

http://support.microsoft.com/kb/274211

I have applied some changes to my code to reduce the number of times the database is opened and closed... hope fully this will resolve the issues...
0
 

Author Closing Comment

by:cycledude
ID: 39998513
the problem appears to have ceased since implementing this solution.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now