>>Occasionally, in our application,(VFP5) some of our clients receive error message 114 (Index does not match the table. Delete the index file and recreate the index). We have tried two ways to solve this programmatically. First, A DELETE TAG ALL command will delete the .CDX file, but only if the table is open (and we can’t open the table because of error 114). Secondly, we’ve tried to use the DELETE FILE command to delete the .CDX file, but since the table has a primary key, when we attempt to open the table, we receive the error “Primary key property is invalid; please validate the database
>>
>>What’s the best way to open a table in this situation so that we can subsequently re-create the corrupted index? Our re-index routine is fairly complete, in that it creates all the necessary indexes, persistent relations, and re-creates the RI code – it’s just that we can’t get the table open without doing it manually in VFP.
>
>
>If possible, backup all and try to re-fill the table!
>Then, the index problem will be auto-fixed.
>
>
>Example code:
>
>
>* Re-Fill Data
>
>Use DataTable EXCLUSIVE
>SELECT * from DataTable Where .T. INTO CURSOR Tmp
>SELECT DataTable
>ZAP
>APPEND FROM DBF([Tmp])
>
Be real careful with this code. If your SELECT generates a "filtered view" and not a real table (a real posibility with a SELECT *), you might not have any data to append after the ZAP! You can get around this problem by adding the NOFILTER clause to your SQL SELECT statement.