[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

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?
0
cycledude
Asked:
cycledude
  • 3
1 Solution
 
Kishan ZunjareCommented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
cycledudeAuthor Commented:
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
 
cycledudeAuthor Commented:
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
 
cycledudeAuthor Commented:
the problem appears to have ceased since implementing this solution.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now