How To Fix Index Corruption at Run Time with Visual FoxPro

Article translations Article translations
Article ID: 168762 - View products that this article applies to.
This article was previously published under Q168762
Expand all | Collapse all

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.

Properties

Article ID: 168762 - Last Review: July 1, 2004 - Revision: 2.2
APPLIES TO
  • Microsoft Visual FoxPro 3.0b Standard Edition
  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition
Keywords: 
kbdatabase kberrmsg kbhowto KB168762

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com