ID: Q114355
2.50 2.50a 2.50b 2.60 3.00 WINDOWS kbinterop
The information in this article applies to:
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.
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:
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
PUBLIC handle
dsource="foxtest"
errval=0
errmsg=""
**** foxtest is a datasource name for a single-tier FoxPro database driver.
handle=SQLConnect(dsource,"","")
=SQLSetProp(handle,"Asynchronous",.T.)
**** The customer table must be in the
sql="select * from customer"
waittime=2
start=SECONDS()
retcode=SQLExec(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=SQLExec(handle,sql)
ENDDO
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)
FoxPro Connectivity Kit "User's Guide," version 2.5, pages 26-27, 31-32, 35, 38-39, and 46-47
Additional reference words: VFoxWin 3.00 FoxWin 2.50 2.50a 2.50b 2.60 ck KBCategory: kbinterop KBSubcategory: FxtoolCk
Keywords : kbcode FxtoolCk
Version : 2.50 2.50a 2.50b 2.60 3.00
Platform : WINDOWS
Last Reviewed: May 22, 1998