Microsoft KB Archive/167906

= The Access 7.0 database cannot be recovered after you call the CDaoWorkspace::RepairDatabase function or the or CdbDbEngine::RepairDatabase function =

Article ID: 167906

Article Last Modified on 6/2/2005

-

APPLIES TO

 The DAO SDK, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.1 Subscription

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul>

 Microsoft Foundation Class Library 4.2</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q167906

<div class="symptoms_section">

SYMPTOMS
If you call CDaoWorkspace::RepairDatabase or CdbDbEngine::RepairDatabase on a corrupt Access 7.0 database, it may result in a database that is so corrupt that it cannot be recovered.

NOTE: This same behavior may occur in Microsoft Access 97 with databases That are converted from Microsoft Access 7.0. If this happens, you should either:

Create a new database in Microsoft Access 97 and import all the objects from a backup copy of the Microsoft Access 7.0 database.

- or -

Use Jetcomp.exe, a stand-alone utility, to compact the database.

<div class="cause_section">

CAUSE
The MSysObjects system table is corrupted.

<div class="resolution_section">

RESOLUTION
You should always call CDaoWorkspace::CompactDatabase before calling CDaoWorkspace::RepairDatabase on an Access 7.0 database. It is a good idea to compact, repair, and backup your database frequently.

<div class="moreinformation_section">

Sample Code
/* Compile options needed: none */

// The following code will repair the database C:\DB1.MDB // using the MFC DAO classes try {       CDaoWorkspace::CompactDatabase( _T( "C:\\DB1.MDB" ),            _T( "C:\\DB2.MDB" ) ); CDaoWorkspace::RepairDatabase( _T( "C:\\DB2.MDB" ) ); }   catch( CDaoException* e ) {       AfxMessageBox( e->m_pErrorInfo->m_strDescription ); e->Delete; }

<div class="references_section">