Problem solve Get help with specific problems with your technologies, process and projects.

Repairing a Microsoft Jet database

This tip gives you a way around with those MS Jet database flags that signal corruption may have occurred.

If Microsoft Jet is writing data at the time when a problem occurs in a database, such as after a power outage or an inadvertent reboot, then the database may have corrupted data.

Jet sets a flag when it's writing to a database. It resets the flag when the write is complete. If the write operation is interrupted, the flag will remain set. Then when you attempt to open the database again, Jet will see that the flag is set and will give a corrupt-database message. Usually the database is not corrupt, but the set flag signals that corruption may have occurred.

You can remedy the situation by using the RepairDatabase method. This method inventories the objects in a database and checks each one for integrity. If there is no corruption, RepairDatabase will reset the write flag. If corruption has occurred then Jet will attempt to repair the database.

Before using this method, remember to make a backup of the database. Be certain that the database is not replicated, because RepairDatabase should not be used on a replicated database. If you do that, the database will no longer be replicable, nor will you be able to synchronize it with other replicas in the set. If a replica is corrupted, you should delete it and create a new replica from another in the set. The RepairDatabase method performs modification on certain system tables in the .mdb file. If the database were to remain a member of the replica set, the modification of the system tables would render the other replicas in the set corrupt. RepairDatabase prevents this from happening by not allowing the database to be replicated, thus preventing synchronization.

Compacting the database after it's repaired. RepairDatabase can recover truncated records of data, but not in Microsoft Jet 3.0 and 3.5 file formats. Repair these versions only if an error message indicates that this is necessary. In Microsoft Jet 3.0, if the RepairDatabase method or command is used before compacting, the database may not be able to open. While the problem of duplicate indexes on a database's system tables has been resolved in Microsoft Jet 3.5, version 3.0 still has this problem. There is an updated release of Jet 3.0 that corrects the problem. It is available here for users of Microsoft Access 95 and other programs that use Microsoft Jet 3.0.

About the Author

Barrie Sosinsky ( president of consulting company Sosinsky and Associates (Medfield MA). He has written extensively on a variety of computer topics. His company specializes in custom software (database and Web related), training and technical documentation.

For More Information

Dig Deeper on Oracle database design and architecture

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.