INF: Asynchronous Query Execution Using VBSQLID: Q121680
|
This article provides the basic information necessary to execute a query asynchronously in a SQL Server front-end using the Microsoft Visual Basic Library for SQL Server (VBSQL).
Queries sent from a Visual Basic front-end to SQL Server can be sent either
synchronously or asynchronously. Synchronous query execution is done by
calling SqlExec% to execute the query. The client program will pause
execution on the SqlExec% line until the query has been completely
processed by the server, and the results returned to the client program.
Because Microsoft Windows is a cooperative multitasking environment, it
may be desirable to allow the user to perform other tasks while a long-
running query is executing at the SQL Server. This can be accomplished by
using asynchronous query execution.
Asynchronous query execution involves using SQLSend% to send the query to
SQL Server, looping until SQLDataReady% returns SUCCEED (1), and then
calling SqlOk% to verify the correctness of the command batch. Inside of
the SqlDataReady% loop, it is necessary to call the Visual Basic function
DoEvents() so that other Windows events can be processed.
Below is an example code fragment that illustrates the function calls:
Result% = SqlCmd%(SQLConn%, Query$)
Result% = SqlSend%(SQLConn%)
While SQLDataReady%(SQLConn%) = 0
dummy% = DoEvents()
Wend
Result% = SqlOk%(SQLConn%)
Additional query words: VB
Keywords : kbinterop SSrvVisB
Version : 4.2 4.21
Platform : WINDOWS
Issue type :
Last Reviewed: March 20, 1999