Recreating the index is not the same as REINDEX. If the table is "free" or you aren't using any referential integrity in the DBC, then you can simply delete the .CDX file for this table and then use the INDEX ON command to recreate the index(es).
This technique assumes that you know what this tables' indexes are. Unfortunately because the index expressions are stored in the .CDX header, when this file gets corrupted you can't do a REINDEX. Note: If you've got a backup of an uncorrupted .CDX for this table, you can restore it, and then the REINDEX will probably work.
If you want to plan ahead for the next time, check out the GENDBC.PRG that comes with VFP, or consider the Stonefield Database Toolkit, which stores this "meta data" in separate tables and makes it easy to fix these and other problems quickly and easily.
How would I find out what the indexes are if I'm not already sure? I'm new to this particular project and unfortunately I'm now the only one involved with it.
Unless you have some external documentation or you have a backup copy of the .CDX, you'll have to read through all the code that accesses this table and "guess" what the indexes are. (Look for SEEK()'s, SET RELATION's, SET ORDER TO, etc.)
You can open the .cdx like it was a regular table and browse it to see what's there.
As for referential integrity, do you have reason to believe that there are breaches in the integrity which have to be considered? I'm not sure that the state of your indexes is directly related to RI.
If you've got a backup .CDX, then you can restore it, and then the REINDEX will probably work (as "Note"d in my first message).
If it does work, then use the Documentation Wizard or GENDBC to get these and the other files Indexes documented.
If this doesn't work, then you'll need a hex viewer program to examine the .CDX file. (You get a free one with VFP - C:\Program Files\Microsoft Visual Studio\Vfp98\Tools\Hexedit\Hexedit.exe.) The file layout for the internal VFP files is partially documented in the Help file: Contents (tab) -> Using Visual FoxPro -> Programmer's Guide -> Appendix -> Compound Index File Stucture (.CDX).
For more details you can also go to C:\Program Files\Microsoft Visual Studio\Vfp98\Filespec\ - there are .DBFs with the info, and even reports to print them out!. (Although there is no more info on .CDXs there.)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.