Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Delete access .mdb problem

Posted on 2003-03-27
10
Medium Priority
?
241 Views
Last Modified: 2013-12-25
Hi,
In deleting .mdb file, I found that sometimes error occur:

permission denied


Is it because I have a corresponding .ldb file that keep some resources that the .mdb file is not allowed to delete?

I have tried to wait until it disappear after I disconnect the database.

If Dir(App.path & "\Database\" & appFileName & ".ldb") <> "" Then
        Do While True
            MsgBox "xx.ldb fading out..."
            DoEvents: Sleep 5000
            If Dir(App.path & "\Database\" & appFileName & ".ldb") = "" Then Exit Do
        Loop
   

But the .ldb never disappear!

What can i do?

1.Is my deduction correct, or is there any other points I have missed out?

2. And can first delete the .ldb file and then .mdb file? Please give me a sound solution ....

Thanks!

cyyam

0
Comment
Question by:cyyam
10 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8218065
it sounds like you have an open connection to the database.Are you connecting to it from VB? Make sure you close the connection and set it to Nothing
0
 

Author Comment

by:cyyam
ID: 8218164
Can I just set it to nothing?
Does it mean already that the conn has been closed?
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8218493
you could check it to see if it is Closed and set to Nothing:

If Not conn Is Nothing Then
    If conn.State <> adStateClosed Then conn.Close
    Set conn = Nothing
End If


you could also do the same for your recordsets.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:WRNewman
ID: 8220526
The ldb element is the msaccess locking file. It will just reappear and dissapear.

The DBengine is the problem. It caches updated data and may not release the db until it has completed.

You should try the following

Assuming your object is mydb
mydb.close
set mydb=nothing
set dbengine=nothing

dbengine intialises when your app starts and does not close until your app closes

If it still persists you could try using another application to delete the db

x=shell("killer.app.exe",1)


0
 
LVL 3

Expert Comment

by:WRNewman
ID: 8220557
A further thought

Are you using XP Office Pro across server 2000

If so there is currently an issue with all Office products causing locking contentions which could prevent you from deleting your db.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8220560
Yes,but aren't you assuming that DAO is being used rather than ADO?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8223849
In case the connectoin with the VB program has been closed and the problem still persists, I hope that the file is not read-only!

Mayank.
0
 
LVL 1

Expert Comment

by:Balshe
ID: 8362119
u should close MDB file
if it's opened from acces u should close this access file


in this sub i want to compact access mdb file then delete old file and rename the new generated file to the old file name :
Sub CompactDB()
Dim DbName As String
DbName = Db2.Name
Db2.Close  ' here i close the database
Caption = "Compacting"
Dim X As String, DbFile As String, Dbpath As String
Dim pos As Long
X = DbName
pos = InStrRev(X, "\")
DbFile = Mid(X, pos + 1, Len(X))
Dbpath = Mid(X, 1, pos)
X = Dbpath & "XX" & DbFile
DBEngine.CompactDatabase DbName, X
Kill DbName
Name X As DbName
' here i re open the file
Set Db2 = DBEngine.OpenDatabase(App.Path & "\School.mdb")
End Sub
0
 
LVL 1

Expert Comment

by:ayufans
ID: 9272353
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- PAQ'd and points NOT refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

ayufans
Cleanup Volunteer
0
 

Accepted Solution

by:
AnnieMod earned 0 total points
ID: 9335070
Per recommendation.

AnnieMod
Community Support Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question