?
Solved

Delete access .mdb problem

Posted on 2003-03-27
10
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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