Solved

C# and MS Access problem

Posted on 2014-01-07
5
187 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
the problem appears to have ceased since implementing this solution.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

11 Experts available now in Live!

Get 1:1 Help Now