Microsoft KB Archive/299020

= FIX: Index Corruption Updating Same Record from Two FoxPro Instances =

Article ID: 299020

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q299020



SYMPTOMS
When Buffering is set to 3 (Optimistic row) and two or more users edit a record and commit changes, the table index may become corrupt, causing blank (&quot;phantom&quot;) records to appear.



CAUSE
Internally, FoxPro calls functions that lock a record and determine that the record was changed by another user. The status of current value of the record is adjusted, but the value for each index is not updated. As a result, an inconsistency is created between the index buffer and the new record.



STATUS
This problem was corrected in Microsoft Visual FoxPro version 7.0 for Windows.



Steps to Reproduce Behavior
  In Visual FoxPro version 6.0 (VFP6), paste the following code in a new program: ON ERROR * TABLEREVERT(.T.) ON ERROR CLEAR ALL CLEAR SET MULTILOCKS ON SET SAFETY OFF PUBLIC mErr mErr = 0

ON ERROR mErr = ERROR USE table1 EXCLUSIVE ON ERROR

IF mErr < 2 DO maketable ? &quot;Making table.&quot; ELSE ? &quot;Not making table.&quot; ? mErr ENDIF

USE table1 ORDER 1 SHARED CURSORSETPROP(&quot;Buffering&quot;,3) REPLACE NAME WITH ALLTRIM(NAME) + IIF(mErr < 2,&quot;x&quot;,&quot;y&quot;) IF mErr >2 ? &quot;TableUpdate: &quot;,TABLEUPDATE(0,.T.) CLOSE DATABASES ALL RETURN ENDIF

PUBLIC ox ox = NEWOBJECT(&quot;myform&quot;) ox.SHOW

DEFINE CLASS myform AS FORM AUTOCENTER = .T.   WIDTH = 350 HEIGHT = 300 MINBUTTON = .F.   MAXBUTTON = .F.    BORDERSTYLE = 2 CAPTION = [] ADD OBJECT cmdUpdate AS COMMANDBUTTON ADD OBJECT grdMyGrid AS GRID PROCEDURE cmdUpdate.CLICK ACTIVATE SCRE ?&quot;TableUpdate: &quot;,TABLEUPDATE(0,.T.) ENDPROC PROCEDURE INIT WITH THIS .grdMyGrid.TOP = 75 .grdMyGrid.LEFT = 20 .cmdUpdate.CAPTION = &quot;TableUpdate(0,.T.)&quot; .cmdUpdate.TOP = 10 .cmdUpdate.WIDTH = 120 .cmdUpdate.HEIGHT = 40 .cmdUpdate.LEFT = 100 IF mErr >2 THIS.cmdUpdate.CLICK ENDIF ENDWITH ENDPROC PROCEDURE DESTROY ACTIVATE SCREEN LIST CLOSE DATABASES ALL ENDPROC ENDDEFINE

PROCEDURE maketable CLOSE DATABASES ALL CREATE TABLE table1 (NAME c(10)) INSERT INTO table1 VALUES ('John') INSERT INTO table1 VALUES ('Mary') INDEX ON NAME TAG NAME ENDPROC  Save the program as Repro1.prg. Then, save the program a second time as Repro2.prg. Be sure to save both programs to the same folder. Run Repro1.prg in this instance of VFP6. Open a second instance of VFP6 and run Repro2.prg. Return to the first instance of VFP6 and click the command button on the form that is displayed. Press the DOWN ARROW key to enter the grid.</ol>

You now see a blank, &quot;phantom&quot; record in the grid. If the Status bar is available, note that there are only two records in the table that the grid is displaying, although the grid seems to contain three records.

Keywords: kbbug kbfix kbdatabase kbvfp700fix KB299020

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.