Microsoft KB Archive/111756

From BetaArchive Wiki

BUG: COPY TO WITH CDX Causes to .CDX to Become Corrupt

ID: Q111756

The information in this article applies to:

  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for Macintosh, versions 2.5b

SYMPTOMS

When the COPY TO command is used with the WITH CDX clause, the .CDX file will become corrupt when following conditions are present:

  • There are deleted records in the table.
  • SET DELETED ON is set.
  • The COPY TO ... WITH CDX command doesn't have a FOR or WHILE clause.

Other symptoms of this problem are the error messages "Index does not match table. Recreate index." and "Table is not ordered."

RESOLUTION

To work around this problem, use a FOR or WHILE clause with the COPY TO command. For example:

   COPY TO <filename> WITH CDX FOR .T.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

Run the following program:

   CLEAR ALL
   CLOSE ALL
   SET DELETED OFF
   CREATE TABLE original (idnum C(3))
   FOR i = 1 TO 100
        INSERT INTO original (idnum) VALUES ( STR( m.i, 3, 0 ) )
   ENDFOR
   INDEX ON idnum TAG idnum
   DELETE FOR RECNO() % 10 = 0
   USE
   USE original
   SET DELETED ON
   COPY TO t_copy WITH CDX

   USE t_copy ORDER idnum
   IF SEEK( " 10" )
        WAIT WINDOW "Seeking 'idnum 10',  we found " + idnum + ;
        ". But we shouldn't have found anything."
   ENDIF

The SEEK(" 10") function call should return .F.; therefore, the WAIT WINDOW should never appear. Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60 buglist2.00 buglist2.50 buglist2.50a buglist2.50b buglist2.60 errmsg err msg KBCategory: kbprg kberrmsg kbbuglist KBSubcategory: FxprgGeneral


Last Reviewed: June 27, 1995
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.