Microsoft KB Archive/317720

= FIX: GETFLDSTATE Indicates Second Record Is Appended After END TRANSACTION =

Article ID: 317720

Article Last Modified on 2/26/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 7.0 Professional Edition

-



This article was previously published under Q317720



SYMPTOMS
When you append records to a table and then use the GETFLDSTATE function, the result may indicate that an additional record has been appended to the table.



RESOLUTION
To resolve this problem, obtain the latest service pack for Visual FoxPro for Windows 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

316964 How to Obtain the Latest Visual FoxPro for Windows 7.0 Service Pack



STATUS
Microsoft has confirmed that this is a problem in Microsoft Visual FoxPro for Windows 7.0. This problem was first corrected in Visual FoxPro for Windows 7.0 Service Pack 1.



Steps To Reproduce Behavior
  Paste the following code in a program (.prg) file and then run the program:
 * 1) DEFINE DBCNAME    'testdb'
 * 2) DEFINE TABNAME    'testtab'

CD (ADDBS(JUSTPATH(SYS(16))))

CLEAR CLOSE ALL DELETE FILE testdb.dbc DELETE FILE testdb.dc? DELETE FILE testtab.dbf

CREATE DATABASE DBCNAME CREATE TABLE (TABNAME) (F1 I PRIMARY KEY, F2 C(8), F3 C(10), F4 i, F5 i) CLOSE DATABASES ALL

DELETE FILE testdb1.dbc DELETE FILE testdb1.dc?

CREATE DATABASE (DBCNAME+'1')

CREATE CONNECTION Conn1 ; CONNSTRING &quot;Driver=Microsoft Visual FoxPro Driver;UID=;&quot; + ; &quot;PWD=;SourceDB=&quot;+ADDBS(JUSTPATH(SYS(16)))+&quot;testdb.dbc;SourceType=DBC;&quot; + ; &quot;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;&quot;

CREATE SQL VIEW &quot;RV_TESTTAB&quot; ; REMOTE CONNECT &quot;conn1&quot; ; AS SELECT * FROM testtab Testtab WHERE Testtab.f1 = ?id

DBSETPROP('RV_TESTTAB', 'View', 'SendUpdates', .T.) DBSETPROP('RV_TESTTAB', 'View', 'Tables', 'testtab')

DBSETPROP('RV_TESTTAB.f1', 'Field', 'KeyField', .T.) DBSETPROP('RV_TESTTAB.f1', 'Field', 'Updatable', .T.) DBSETPROP('RV_TESTTAB.f1', 'Field', 'UpdateName', 'testtab.f1') DBSETPROP('RV_TESTTAB.f1', 'Field', 'DataType', &quot;I&quot;) DBSETPROP('RV_TESTTAB.f2', 'Field', 'KeyField', .F.) DBSETPROP('RV_TESTTAB.f2', 'Field', 'Updatable', .T.) DBSETPROP('RV_TESTTAB.f2', 'Field', 'UpdateName', 'testtab.f2') DBSETPROP('RV_TESTTAB.f2', 'Field', 'DataType', &quot;C(8)&quot;) DBSETPROP('RV_TESTTAB.f3', 'Field', 'KeyField', .F.) DBSETPROP('RV_TESTTAB.f3', 'Field', 'Updatable', .T.) DBSETPROP('RV_TESTTAB.f3', 'Field', 'UpdateName', 'testtab.f3') DBSETPROP('RV_TESTTAB.f3', 'Field', 'DataType', &quot;C(10)&quot;) DBSETPROP('RV_TESTTAB.f4', 'Field', 'KeyField', .F.) DBSETPROP('RV_TESTTAB.f4', 'Field', 'Updatable', .T.) DBSETPROP('RV_TESTTAB.f4', 'Field', 'UpdateName', 'testtab.f4') DBSETPROP('RV_TESTTAB.f4', 'Field', 'DataType', &quot;I&quot;) DBSETPROP('RV_TESTTAB.f5', 'Field', 'KeyField', .F.) DBSETPROP('RV_TESTTAB.f5', 'Field', 'Updatable', .T.) DBSETPROP('RV_TESTTAB.f5', 'Field', 'UpdateName', 'testtab.f5') DBSETPROP('RV_TESTTAB.f5', 'Field', 'DataType', &quot;I&quot;)
 * !* Field Level Properties for RV_TESTTAB
 * Props for the RV_TESTTAB.f1 field.
 * Props for the RV_TESTTAB.f2 field.
 * Props for the RV_TESTTAB.f3 field.
 * Props for the RV_TESTTAB.f4 field.
 * Props for the RV_TESTTAB.f5 field.

USE rv_Testtab SHARED NODATA

=CURSORSETPROP(&quot;Buffering&quot;,3) && same with 5

? &quot;  First Call To AddData&quot; =AddData(500)
 * Add the first record to the table.

? &quot;  Second Call To AddData&quot; =AddData(501)
 * Add the 2nd record to the table.

RETURN

PROCEDURE AddData(lnNewVal) id=0 =REQUERY(&quot;rv_Testtab&quot;) SELECT rv_Testtab APPEND BLANK REPLACE F1 WITH m.lnNewVal, F2 WITH ALLTRIM(STR(m.lnNewVal)), ; F3 WITH ALLTRIM(STR(m.lnNewVal)), F4 WITH m.lnNewVal, ; F5 WITH m.lnNewVal ? &quot; Before Transaction: &quot;+GETFLDSTATE(-1,&quot;rv_Testtab&quot;),F1 BEGIN TRANSACTION ? &quot; GETFLDSTATE In Transaction Before Table Update:        &quot;+GETFLDSTATE(-1,&quot;rv_Testtab&quot;),F1 ? &quot; Table Update Results: &quot; + IIF(TABLEUPDATE(0,.f.,&quot;rv_Testtab&quot;), &quot;True&quot;, &quot;False&quot;) ? &quot; GETFLDSTATE In Transaction After Table Update:  &quot;+GETFLDSTATE(-1,&quot;rv_Testtab&quot;),F1 END TRANSACTION * After the second record has been added and the transaction is done, * GETFLDSTATE shows that another record has been appended when * this is not the case. ? &quot; GETFLDSTATE After End Transaction: &quot;+GETFLDSTATE(-1,&quot;rv_Testtab&quot;),F1

ENDPROC  Examine the results as follows:  After the first record is added to the table, the results from GETFLDSTATE after the END TRANSACTION command return all 1s, which indicates that the field has not been edited. After the second record is added to the table, the results for the GETFLDSTATE after the END TRANSACTION command return all 3s, which indicates that the field in the appended record has not been edited. The GETFLDSTATE function reports that another record has been appended to the table even though no record has been added.</ul> </li></ol>

Additional query words: kbVFP700sp1fix

Keywords: kbbug kbfix kbcodesnippet KB317720

-

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

© Microsoft Corporation. All rights reserved.