Unlock MS Asscess Databases

My site uses an Access database thorugh a DSN Connection. Every once in a while, I get a page that doesn't completly work, and the code to close the database sticks the databse open, and I get an ldb file.

Since every page in my site uses the database, If I don't close the database, I eventually lock the site up.

I've tried deleting or renaming the ldb fle from ftp, but I can't. Is there a script (I use vbscript) of some sort that can unlock the database?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Stop web site, and then delete it.
Be sure to close all your recordset and connections to database after you have opened them.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
While using an Access database for web stuff is not unheard of, it is definitely not the best practice. I would recommend migrating to an MSDE or SQL Server 2000 platform if possible. If not, then you might want to try:
1. using a DSNless connection vs. DSN.
2. take a look at how your recordsets are using the tables, recordlocking, etc..
3. might be a network issue if the database resides on a network share.
4. the database might become extremely bloated, try running a nightly batch script to compact and repair the database.

note: Access always creates a lockfile when the database is opened.
I agree with both, but masirof has a point

If you dont close the database connection in every page then every time you navigate to another one you are opening another database connection, MSaccess can only handle about 25-30 connections at once, and that is on a very very Good day!!!
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

It looks like all possibilities have been covered but showing the code eliminates the guesswork.
MoMarviAuthor Commented:
Sorry this has taken so long

Sometimes, stopping the website doesn't release the lbd file.

I would love to use something more robust than Access, but there are several reasons to use it for now.
Why would a DSNLess connect work better? I thoguht a DSN was more efficient.
I know my problem has to be with not closing all my connections. My code was pretty sloppy when I started. I am tracking down the leaks, but it takes a while with several hundred pages.
It's not a network issue, since the db is on the same folder as the rest of the site
The database may be becoming bloated. I'll have to look into compacting on the server.

I think as I said to Jokra_the Barbarian that I have a leak or ten by not closing connections.

Since I'm not sure of where the rest of my leaks are, posting the code is highly improbable, unless you have a Bambleweenie 2000 Matrix Generator, and a really hot cup of tea (Sorry, I'm waiting for the Hitchhikers Guide to the Galaxy Movie to come out)


Not showing relevant code is not going to get you much help.
A DSN-less connection is more efficient because it doesn't have to pass the connection off, it just connects directly.  Doing one thing is more efficient than than doing two things.
If you have leaks, then close connection and destorys objects.

If you have an open connection, and it's called conn, then:


Same for recordsets:


Then destroy the objects:

set conn = nothing
set rs = nothing

In VBScript, an obect is defined by 'set'.  So, if you created an object, destroy it.  Simple.  Just match the sets.
MoMarviAuthor Commented:

I know about the leaks, and I am hunting them down. I know how to close and destry connections, I just got a bit sloppy in my initial coding.

As I said before, I have 150 separate pages that call the database, so picking the code to show is a bit daunting. My question had to do with how to unlock a locked database, until I track down the leaky code.

Any Ideas?

You shouldn't have a locked database.  You should also consider using includes and put common routines in one file, rather than putting the same routine in multiple files.  Also, if you're using ODBC, I'd recommend against it.

See if this will help for now:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I appreciate any comments that would help me to make a recommendation.

Unless it is clear to me that the question has been answered I will recommend delete without refund of points.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade.  It is assumed that any participant not responding to this request is no longer interested in its final disposition.

If the user does not know how to close the question, the options are here:

EE Cleanup Volunteer
Never got a reply.
MoMarviAuthor Commented:
It's taken a while, but I've tracked down all my leaks, and resolved the issue.

masiroff was correct. It just took along time to track down all the open connections.

My original question was how to unlock a locked acces database. Even stopping IIS will not unlock a locked access database. A full reboot (Not fun to ask for on a shared server) seems to be the only way to unlock the database.

IIS has nothing to do with Access.  Access is not an application server like MS SQL.  A full reboot is not required.  You have another option.

MoMarviAuthor Commented:

HostMySite is my host, and they never suggested this during our discussions.

They may not know it is an option.  I would think they gave you a truthful answer based on their knowledge in this area.
MoMarviAuthor Commented:
I have dealt with several hosts in the past couple of years, and HMS has been by far the best. HSB has been orders of magnitude better than any host I have used, including one that was a branded site of a huge US PC manufacturer.

I'll let this one by.
I'm not familiar with them but I'm sure there are plenty of good hosts out there.  I have been happy with discountasp.net, actwd.net and exabytes.com.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.