Microsoft KB Archive/114355

= INFO: Single-Tier Drivers Don't Support Asynchronous Processing =

Article ID: 114355

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.6 Standard Edition

-



This article was previously published under Q114355



SUMMARY
After you have set the connection option to Asynchronous using the Connectivity Kit's DBSetOpt command, DBExec commands are still processed synchronously when you are using a single-tier driver. The asynchronous connect option works only with two-tier drivers; it is ignored when you are using a single-tier driver.



MORE INFORMATION
A single-tier driver is a driver that directly reads from and writes to a database such as the FoxPro, Btrieve, dBASE, Microsoft Excel, and text file drivers. A two-tier driver is a driver that connects to another DBMS such as SQL Server and ORACLE.

NOTE: dBASE is manufactured by a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.

The Asynchronous connection option works with two-tier drivers only if a connection is actually made. When a DBExec command is processed with the connection option set to Asynchronous, the DBExec command has to be continually called until all the results are returned.

If the code below is run through a trace, it demonstrates that the single- tier driver processes the SQL statement synchronously. Note that the DO WHILE statement is never executed.

NOTE: Depending on your version of FoxPro, use one of the following two code examples:

FoxPro 2.x Code:
SET LIBRARY TO SYS(2004)+"fpsql.fll"

PUBLIC handle dsource="foxtest" errval=0 errmsg="" * foxtest is a single-tier FoxPro database driver. handle=DBConnect(dsource,"","") =DBSetOpt(handle,"Asynchronous",1)

sql="select * from customer"

waittime=2 start=SECONDS retcode=DBExec(handle,sql)

* This DO WHILE code below is never executed because retcode=1....  * i.e., the DBExec above returns all the results synchronously. DO WHILE ((retcode=0) AND (SECONDS - start < waittime)) retcode=DBExec(handle,sql) ENDDO

IF (retcode= 0) retcode=DBCancel(handle) ENDIF

IF (retcode != 1) error=DBError(handle,@errmsg,@errval) CLEAR @ 2,2 SAY errval @ 3,2 SAY errmsg ENDIF

Visual FoxPro Code:
PUBLIC handle dsource="foxtest" errval=0 errmsg="" handle=SQLConnect(dsource,"","") =SQLSetProp(handle,"Asynchronous",.T.)
 * foxtest is a datasource name for a single-tier FoxPro database driver.

sql="select * from customer"
 * The customer table must be in the

waittime=2 start=SECONDS retcode=SQLExec(handle,sql)

DO WHILE ((retcode=0) AND (SECONDS - start < waittime)) retcode=SQLExec(handle,sql) ENDDO
 * This DO WHILE code below is never executed because retcode=1....
 * i.e., the DBExec above returns all the results synchronously.

IF (retcode= 0) retcode=SQLCancel(handle) ENDIF

IF (retcode < 0) val=AERROR(atmp) errval=atmp(1,1) errmsg=atmp(1,2) WAIT WINDOW STR(errval)+': '+errmsg CLEAR ENDIF

***** Remove the connection =SQLDisconnect(handle)

