An access database might get corrupt due to power interruption while the database is open or for several other reasons. You can deduce this by errors it prompts, abrupt behavior, and issues while updating the database. Regardless of the cause, a corrupted database can be easily salvaged using commercial access database repair applications, in case no valid backup is available. However, there are methods too.
To illustrate, consider you use an Access Database with a table containing 'x' number of records. When you view the Autoincrement Id for a new record, it shows the table with lesser records and a difference of 'y' records than the original. Trying to update the table gives an error message, as below:
“Primary index is not unique”
You use DbEngine.CompactDatabase code to try compacting the database, but it deletes the last 'y' records without displaying any error message.
Cause
Access database is corrupt. Using DbEngine.CompactDatabase for a corrupted database might cause data loss.
Solution
It is suggested to backup the database before applying any repair solution. To repair the corrupted Access database, you should use 'Compact and Repair' utility as follows:
Access 2007:
Close the database
Start Microsoft Access and click 'Microsoft Office Button'
Point to 'Manage' and click 'Compact and Repair Database' under 'Manage this database' section
Browse to the affected database in 'Database to Compact From' dialog box and double-click it to start the repair process
Access 2003 and earlier:
Close the database
Launch the application and click 'Tools' menu
Point to 'Database Utilities' and click 'Compact and Repair Database'
Browse to the corrupted database in Database to Compact From' dialog box
Click 'Compact' and proceed as per the instructions
Open the database after the repair process completes. If it still shows corruption symptoms, you need to apply third-party tools for repairing damaged Access databases.
access repair software are powerful utilities, which are exclusively designed for fixing corruption errors with MDB files. These applications come integrated with interactive interface and allow for easy Access Database Repair in any instance of database corruption.