简体   繁体   中英

How can I open a locked mdb file?

I have a database that is locking mdb's and such that I'd like to backup. However the tool (I have the source) I am using opens the file before backing it up and finds that it is locked.

Is there a way I can open it for read-only purposes?

For reference the tool uses C# and .NET 2.0 (but can be updated to 3.5).

The reason your tool locks the file is to prevent changes to the file as it is being backed up. For example, if you begun your backup, but halfway in the DBMS (ie SQL Server) decided to make a change to a file, then your backup would be corrupt.

I recommend you use the tools that are provided with your database solutions to perform a backup. The other option is to stop the database before backing it up.

If the DBMS is holding a write lock on the file, and you read it, you're risking the DBMS writing the file as you're reading it. Depending on what part was written, you could end up with a corrupt backup of the file. You're best off reading the file only if the DBMS isn't writing to the file or letting the DBMS handle its own backups.

This is similar to this question:

Opening a file's Shadow Copy if the current copy is in use

It depends on how the database is opening the MDB file. If it's not allowing read sharing then you're out of luck unless you are able to open the shadow copy. There's a discussion on how to do this here:

How do I copy a file or folder that is locked under windows programmatically?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM