Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access Database locked!

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Dear All,

I am trying to delete an MS Access Database, however it is telling me that The Source or Destination File may be in use. And I am sure that the database is not open on my localhost! I tried to reset my PC and IIS, however, it is still appearing as open (database.ldb). How can I make it inactive, since I think that it is also affecting the pages i am viewing on the localhost.

Thanks for your help and time
 
1. Check if you have any Session or Application code in global.asa file that access the database.

2. Check if you have any application that starts with the system and uses that database.


________
George, M
 
Hello Shaddow, I do not use a global.asa but I pass session variables, and this is a "copy and paste script", ie I always use the same code and it has never happened before.

2) No other Application uses this database. The funny thing is that on the server, everything works fine, only on the localhost, so it has someting to do with the IIS I guess
 
Try to stop IIS and see if the ldb file disepears. If so then you must have an global.asa which uses the file. Some Application_OnInit function somewhere.

________
George, M
 
I already tried to stop IIS but the .ldb file is still visible, although I refreshed the folder.

Can't get the hack out of it yet! Really strange! It only happened this morning, and I have been working on this code for about a week, that is why i am lost!
 
Check the Date/TIme Created/Modified/Accesed of the mdb and ldb

________
George, M
 
Hello Shadow,

You just mentioned the Date/Time Created/Modified, and I am thinkning that since I have implemented this function, that the database is being left open! But only on the localhost!

To reply to your question:-

mdb file :- modified 2/11/2004 12:36
ldb file := modified 2/1//2004 13:46
 
Does this code affect the IIS and leaves the database open?

path=server.mappath("../../../databases/") & "/merlin.mdb"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(path)
lastmodified=f.DateLastModified
lastmodified=dateAdd ("h",6,lastmodified)

Do I have to close the this object?

Help me out please
 
Not actually, you didnt open the file you just read some of it's properties.

Also ldb file will only apear if the mdb file it's opened by the Database driver. No other file access mode will not create the ldb file.

________
George, M
 
So basically I think the only solution is to rename the database and see if it happens again.
 
I tried to remove this code:-

path=server.mappath("../../../databases/") & "/merlin.mdb"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(path)
lastmodified=f.DateLastModified
lastmodified=dateAdd ("h",6,lastmodified)

And now it is working fine on the local host. So I am sure that this code is causing the .ldb problem on the local host. Do you have any idea on how I can go around this?
 
Preatty weird, i've used your code to a mdb file and worked ok.

Not shure but you also could try to set the f to nothing and so the fso object
Code:
path=server.mappath("../../../databases/") & "/merlin.mdb"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(path)
lastmodified=f.DateLastModified
lastmodified=dateAdd ("h",6,lastmodified)

set f=nothing
set fso=nothing

________
George, M
 
Hello Shaddow,

I tried to include

set f=nothing
set fso=nothing

but still the page got stuck!

The problem seems to be in this line (on on the localhost!)

Set f = fso.GetFile(path)
 
This line doenst open the file, i still dont understand why the mdb file it's opened.

The only way i've seen the ldb file it was when i've forgot to close a connection to that file or when was opened by Access.

________
George, M
 
I also ran a special script to be sure that the session is closed:-

response.expires = 0
Session("username") = "" 'Access lasts for session
Session.Abandon()
response.redirect("login.asp")

but it is still opened!
 
Try to stop IIS service...
There is any posibility that somone could keep the file opened? from a share or something?

________
George, M
 
I already tried to stop the IIS but to no avail.

No i am only using the database on the localhost, the others use it from the server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top