Skip to page content or Skip to Accesskey List.

Work

Main Page Content

Unlocking Ms Access Mdb Files

Rated 4.03 (Ratings: 9)

Want more?

 
Picture of isaac

Isaac

Member info

User since: 14 Dec 1998

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"). ;)

SELECT cutemeerkats

FROM whereveryoucanfindthem

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.

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

evolt.org Evolt.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.