HOWTO: Fixing Index Corruption at Run Time with Visual FoxPro

Last reviewed: May 22, 1997
Article ID: Q168762
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0b, 5.0, 5.0a

SUMMARY

When index corruption happens at run time under the Foxpro 2.0, 2.5, or 2.6 platforms, you can easily erase the IDX/CDX files and re-create them. But under the Visual FoxPro environment, once the table is bound to a database and it has Primary index, you cannot erase the CDX file because it generates "Primary key property is invalid, please validate database" error when you try to open the table again in the database.

Re-creating the index on an erased CDX file that only has regular, candidate or unique index generates the following error:

   Invalid database - please validate database

MORE INFORMATION

One option for re-creating corrupt indexes is to use GenDBC.prg to re- create your Database structure and indexes, and then restore the data back to each table. Another option is to use the following steps to restore your corrupted index files:

  1. Create a table and its indexes, and bind it to a Database.

  2. Before you input any data into the table, backup the associated .cdx file.

  3. If the table already has data in it, copy the table to a different name and delete it. Backup its .cdx file.

  4. When the index file becomes corrupted, copy the backup .cdx file back to the corrupted .cdx file (overwrite it).

  5. Open the Table and issue the "Reindex" command.


Keywords : FxprgTable kberrmsg vfoxwin
Version : 3.0b 5.0 5.0a
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.