Microsoft KB Archive/261267

= PRB: FoxPro Tables Accessed Through ODBC Are not Updated =

Article ID: 261267

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Open Database Connectivity Driver for Visual FoxPro 5.0
 * Microsoft Open Database Connectivity Driver for Visual FoxPro 3.0
 * Microsoft Open Database Connectivity Driver for Visual FoxPro 4.0
 * Microsoft Open Database Connectivity Driver for Visual FoxPro 5.0
 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q261267



SYMPTOMS
Applications that access Visual FoxPro tables through Open Database Connectivity (ODBC) may not present current data immediately after the tables are updated from Visual FoxPro.



CAUSE
The Visual FoxPro ODBC Driver caches data for approximately five seconds.



RESOLUTION
This behavior may be circumvented by first disconnecting from and then reconnecting to the Visual FoxPro ODBC data source.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Create a program file named ODBCtest.prg by using the following code: *!* Use the sleep function, so that timing isn't changed by inadvertent key presses DECLARE Integer Sleep IN &quot;KERNEL32.DLL&quot; Integer IF !FILE('TEST.DBF') CREATE TABLE TEST (STATFLD C(10)) INSERT INTO TEST VALUES (&quot;TRUE&quot;) ENDIF IF !FILE('CAPTURE.DBF') CREATE TABLE CAPTURE (t_interval i, actual C(10), expected C(10)) ENDIF CLOSE ALL SET EXCL OFF gnconnhandle=SQLSTRINGCONN(&quot;driver=Microsoft Visual FoxPro Driver;SourceType=dbf;&quot; + ;  &quot;SourceDB=&quot; + SYS(5) + SYS(2003) + &quot;;Exclusive=NO;BackGroundFetch=NO;Deleted=NO&quot;) sqlcommand=&quot;select statfld from test&quot; ? &quot;Interval&quot;,&quot;Actual&quot;,&quot;Expected&quot; FOR alpha=1 TO 5 FOR i=1 TO 5 *!* Use test here, so that we can update it from VFP USE TEST IF ALLTRIM(STATFLD)=&quot;TRUE&quot; REPLACE STATFLD WITH 'FALSE' ELSE REPLACE STATFLD WITH 'TRUE' ENDIF real=TEST.STATFLD USE IN TEST *!* Halt execution for alpa*1000 milliseconds =Sleep(alpha*1000) =odbcdatatrap(real) ENDFOR ENDFOR =sqldisconn(gnconnhandle) SELECT CAPTURE BROWSE TIMEOUT 60 clear dlls
 * !* Test For Caching using ODBC
 * !* Start with a one second delay and increase by one second each iteration
 * !* Done with the ODBC data source, so disconnect

PROCEDURE odbcdatatrap PARAMETER realval *!* Actual Value passed, so execute the ODBC call =sqlexec(gnconnhandle,sqlcommand,'sqlresult') SELECT sqlresult *!* Insert the Interval, Returned Value and the Actual Value into the capture table INSERT INTO CAPTURE VALUES (alpha,sqlresult.STATFLD,realval) ? alpha,sqlresult.statfld,realval  Save and run the program file. Note that the values returned through ODBC do not necessarily match the value of the source table until the interval between queries of the ODBC data source reaches approximately five seconds.

(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by John Desch, Microsoft Corporation.

Keywords: kbcodesnippet kbdatabase kbprb KB261267

-

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

© Microsoft Corporation. All rights reserved.