Dabblernl
Dabblernl

Reputation: 16101

VB6 application keeps lock on Access (.mdb) database after creation, causing an error 3028

Our application builds an Access database (.mdb) and then starts a different application with the Shell command which needs Read/Write Access to this very database. The problem is that on some systems our application seems erratically to retain an exclusive lock on the database, preventing the other application from accessing it. Only after closing down the first application can the other application proceed.

The specific Error that is raised is Error 3028, which seems to be specific for DAO 3.51 (Access '97) which we indeed employ. I cannot understand why some systems are affected (and then not consistently) and others never. I thought that it might be a timing issue and built in a Sleep period between building the database and launching the other application, but that does not help.

What is going on?

EDIT: I now created a workaround by creating the database in a separate file and then copying it. Now the second program should always be able to access it and any remaining lock problems will surface in the first program, which I maintain. I will follow up later when our users have been able to test this.

Upvotes: 2

Views: 1391

Answers (2)

George
George

Reputation: 2213

Are you closing the connection to the DB before passing control to another EXE?

Upvotes: 2

Matt Donnan
Matt Donnan

Reputation: 4993

I had a similar issue previously which wasn't quite the same but from what you have described this is the approach I would try:

Before lauching the secondary application with the shell command.

Alongside the sleep period you have already employed you will also need to close the original program which generated the .mdb file.

I achieved this by shelling a windows batch file, and then immediately exiting the original program.

Batch file makeup as follows:

ping -n 5 localhost >NUL
start MSAccess.exe "C:\DB.mdb"
exit

This allows 5 seconds for the mdb file to be freed-up before launching, you could replace my Ms Access call with your secondary program.

Upvotes: 0

Related Questions