Skip to page content or skip to Accesskey List.
Search evolt.org
evolt.org login: or register

Work

Main Page Content

Unlocking MS Access MDB Files

Rated 4.03 (Ratings: 9) (Add your rating)

Log in to add a comment
(13 comments so far)

Want more?

 
Picture of isaac

Isaac

Member info | Full bio

User since: December 13, 1998

Last login: October 27, 2007

Articles written: 67

As a ColdFusion newbie about a year ago, I can distinctly recall the frustration of dealing with Microsoft Access database files which had been "locked" by the ColdFusion Application Server accessing them. I can remember being unable to delete or overwrite older database files, and trying stupid workarounds like uploading newly named databases (and having to change the resulting ODBC System DSN).

The solution is incredibly simple, as will be this article. The trick to unlocking the hold on the MDB file is to simply throw it a query that will cause an error. The easiest way to do that is to attempt a select from a table that doesn't exist. Code like this should do the trick (unless you're really strange and actually have a table named "whereveryoucanfindthem" and a field named "cutemeerkats"). ;)

<cfquery name="unlockmdb" datasource="dbnamegoeshere">
  SELECT cutemeerkats
  FROM whereveryoucanfindthem
</cfquery>

Place this snippet into a file (I call mine die.cfm), and then run it whenever you need to unlock the database. It could even be extended to accept a datasource name via the query string and unlock any database on your machine, but I'll leave that to anyone who wants to try it as an experiment (my goal here is for simplicity).

Hopefully anyone new to CF and databases who has struggled with this issue in the past will have to suffer no longer. I encourage anyone with questions or information relevant to this article to comment below. If you've got alternate solutions or warnings, be sure to pass them on.

isaac

Isaac is a designer from Adelaide, South Australia, where he has run Triplezero for almost a decade.

He was a member and administrator of evolt.org since its founding in 1998, designed the current site, and was a regular contributor on evolt.org's direction-setting discussion list, theforum.

On the side, he runs Opinion, Hoops SA, Confessions, Daily Male, and Comments, as well as maintaining a travel gallery at Bigtrip.org.

Submitted by mrnick on November 1, 2000 - 18:02.

Very interesting... I am going to make die.cfm now and put it in my link bar. I have previously just killed cfserver.exe and restarted it if it is on a local box, but this is way easier.

login or register to post comments

Submitted by agraetz on November 10, 2000 - 10:22.

If I understand the problem right, it sounds like what you really want to do is go into the CF Administrator and open up the datasource for your application. Once you're in there, deselect the box so that the CF app server will not keep a constant connection. Once you do this, it won't constantly keep the database locked up. Like I said, I'm not sure about exactly what the circumstances are when you're having the trouble with the access database remaining locked. But if I do understand it, I would imagine this solution is better than sending the database a bad SQL statement.

login or register to post comments

Submitted by jedimaster on November 17, 2000 - 15:48.

I think this is a performance issue. In general, you should keep the db connection turned on if the site is live. If your playing around on a test server, then yes, it's best to turn off that option.

login or register to post comments

IT IS THE solution i was looking for!

Submitted by premanands on September 2, 2001 - 21:10.

I am a webmaster for a website. As I use the Access database i the main page, it was impossible to be to make changes in the database as it was always locked. I was waiting all the time to see when it would unlocked. I searched in Google about unlocking the access DB and it got me to this page. It was the ultimate solution for my problem. Who invented it?? I am grateful to him. Hope this forum helps me in fixing a lot of such problems. Prem

login or register to post comments

"invented" ?

Submitted by jedimaster on September 4, 2001 - 07:07.

I don't think this was invented per se, it's just how Access is unlocked, or can be. Again, the best option is to turn off the maintain db thing, since, in theory, you should NOT be changing your DB while your site is live. Of course, we all know how far theory is from reality. ;)

login or register to post comments

I HOPE IT IS THE SOLUTION I'VE BEEN LOKING FOR

Submitted by KEVIN on September 20, 2001 - 22:34.

I DONT KNOW WHAT A COLD FUSION SERVER IS, WILL THIS WORK FOR MY SHARED FILE APPLICATION ON ACCESS97. I WROTE IT FOR A GROUP OF PEOPLE AT WORK, AND I HAVE TROUBLE UPDATING IT, BECAUSE PEOPLE ARE IN IT (LOCKED). THE LOGIC I WROTE TO KICK PEOPLE OUT WITH TIMERS ON HIDDEN FORMS SEEMS DEFEATED WHEN THEY DONT HAVE IT CURRENT ON THERE DESKTOP (MINIMIZED, I GUESS). I'LL TRY THIS BUT IM OPEN TO CLEARIFICATIONS ON MY PROBLEM. iVE ALSO HEARD OF SOME CODING THAT GOES INTO EFFECT WHEN THE FORM IS NOT ACTIVE OR NOT ON DESKTOP, BUT I DONT KNOW THE RIGHT VB CODE.

login or register to post comments

this sound good but confusing

Submitted by msmysailor on June 30, 2002 - 08:13.

Can you please explain in simpler formI am a mother of 5 and my brain is fried but would love to try this on a file i would like to use for home billing business. Thanks you

login or register to post comments

Guru

Submitted by Goldenyogi on April 2, 2003 - 23:41.

I am a newbie in this MS Access DB. I've tried to understand and crack this thing for the last few wks unsuccessful. Plzzzzzzzzzzz help. http://www.mortgagecoach.com/download/432/mtgcoach432c.exe Your expertice and advice will greatly be appreciated,

login or register to post comments

Any Other Workaround

Submitted by ctromb on March 4, 2004 - 06:35.

I have tried your suggestion, but it has failed to unlock database on servers where my sites are hosted, this is quite aggrevating when I need to get work done, and have to wait sometimes up to an hour for the locked database to be released. Any ideas would be greatly appreciated. Thanks in advance.

login or register to post comments

A Brilliant Fix

Submitted by rivercitysource on February 4, 2007 - 23:26.

This message may show up twice, but it appears that my first message may have been accidental spam, probably because I listed the website that I implemented this fix on. Anyway, just wanted to say that operation killdb.cfm (a.k.a. die.cfm) is in full effect at [my site] and is working great! It is simple, and works perfectly for the stubborn .ldb problem in MS Access. Thanks for the fix, I am now a member of this site because of it! Cheers!

login or register to post comments

Cannot delete the LDB

Submitted by suman on October 25, 2007 - 04:40.

I created an access in access2003 , its being used in multiuser environment ..based on a particular value the database is automatically closed and only i can change the value. Even after the database is closed the .ldb file exist .. Now I tried your code die.cfm , not very sure how to use it , because with the .cfm extension its not getting executed , can you suggest how can i get it executed ?, Or should I create a false query within the database so that it throws the error , but then while running the query I have to login to the database that will create the lock file .. The os used is Win Xp and the file is placed on a common shared drive. suman sengupta

login or register to post comments

cannot delete the laccdb

Submitted by tel on January 17, 2008 - 14:42.

I have a lock on our MSA 2007 database, no one is actually logged in but the registry did not clear in the iaccdb lock file so it constantly remains in a locked status. I can't use the above formula as I am not directly running cfm, so can someone help me with a workaround?, can I set up a msaquery inside the database that will unlock users. Tel

login or register to post comments

How to, just using MS Access

Submitted by whippsa on March 4, 2008 - 16:04.

Open the Access locked database, Make a new query but don't select any tables. Go to SQL view Type: select a from b; Run with the ! It gives an error because you have no table called 'b' You can save the query which tells you the MDB is no longer locked. Close the database and it is unlocked! There is no LDB

login or register to post comments

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.orgEvolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.