Did you notice you can overwrite an open access (mdb) database?

Posts   
 
    
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 24-Nov-2008 15:16:27   

Some week ago I stumbled on a weird issue. I found that it's possible to overwrite an open access DB. No matter if I also have some table of this DB opened in Access GUI, or if there is some instance of .Net application hooked on this DB, I can still overwrite the mdb file.

Of course, I can't delete or rename the MDB, and I can't rename or delete the LDB file... but i believe it's very weird that I can overwrite the MDB itself. confused

I tried this experiment on 2 different computer using WinXP SP3 x32, and Access 97 / Access 2003 SP3, using MDB file on local path, obtaining the described result.

Do you think there is something wrong on my Dev computer? confused

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 24-Nov-2008 16:18:31   

Files can be overwritten unless there's a lock on the file. I think (but that's guessing) that if there's no live connection open to the access db, the file isn't locked. (although it can be the file is never locked as that would probably be problematic with multiple users).

Frans Bouma | Lead developer LLBLGen Pro
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 25-Nov-2008 10:47:57   

Otis wrote:

Files can be overwritten unless there's a lock on the file. I think (but that's guessing) that if there's no live connection open to the access db, the file isn't locked. (although it can be the file is never locked as that would probably be problematic with multiple users).

I never really thought about how access DB work, I mean, I know it's only a shared file some client DLL, but I just realized that one of the implication is that any client, and any application, must me able to open the access MDB file for writing. So you can overwrite it. This is a dangerous implication, because any client application can corrupt the DB, if something go wrong... but probably there isn't anything we can do about that. (apart using a real DB Server simple_smile