Effects of Asynchronous Queries

If your ODBC driver, database server, and network operating system support asynchronous operations, Microsoft Jet executes ODBC queries asynchronously. This allows your application to cancel a long-running query or to switch to another task while the query runs on the server. Microsoft Jet interrogates the server at the interval specified by the value of the AsyncRetryInterval setting in the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\ODBC key in the Windows Registry. By default, this value is set to 500 milliseconds.

If your application cancels an asynchronous query (or closes the query before all results have been retrieved), Microsoft Jet calls the ODBC SQLCancel function. The SQLCancel function discards any pending results and returns control to the application. Some database servers or network operating systems respond quickly to query cancellations; others may require your application to wait several seconds.

In addition, Microsoft Jet cancels a query when the interval specified by the value of the QueryTimeout setting in the \HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\Jet\3.5\Engines\ODBC key in the Windows Registry is reached. By default, this value is set to 60 seconds. A timed-out query isn’t necessarily an indicator of trouble on the server; it simply means that the query did not return results in the time allotted. If you plan to execute a lengthy query, you can set the query’s ODBCTimeout property to override the value of the QueryTimeout setting in the Windows Registry.

See Also For more information on setting the connection timeout, see “Setting Connection Timeout” later in this chapter. For more information on Registry settings, see Appendix C, “Registry Settings.”