The information in this article applies to:
SYMPTOMSUsing a Close method on a database opened with Open Database Connectivity (ODBC) drivers doesn't close the database. The ODBC database process keeps running. To close the connection successfully, you must end the Visual Basic application. CAUSEAfter Visual Basic executes the Close method on an ODBC connection, the Microsoft Access engine in Visual Basic maintains a persistent connection in case the user reopens the database later in the program. This makes the program more efficient. RESOLUTION
If a Visual Basic program does not reopen the ODBC connection after doing a
Close method, a time-out occurs and the connection closes automatically.
The default ConnectionTimeout is usually 600 seconds (10 minutes). The lowest supported ConnectionTimeout value is 1 second. A ConnectionTimeout value of 0 says to never cause a time-out. To enforce the fastest possible time-out, you can set ConnectionTimeout to 1. In addition, you can add the following code after you close the database to make sure the connection is terminated:
This loop delays for a second after the db.Close. The FreeLocks statement tells the database engine that the user is idle. If you run the Visual Basic program with ConnectionTimeout set to 1 in your VB.INI or <vb_exe_app_name>.INI file, the database engine will disconnect the one-second-old connection to the server. STATUSThis behavior is by design for all ODBC database connections. MORE INFORMATIONReproducing the BehaviorFor example, using a Close method on a database opened via an ODBC connection to a Sybase SQL server leaves the Sybase session open. You can confirm this by executing sp_who on the Sybase server.As another example, assume you have a Visual Basic application on a timer that regularly checks SQL Server version 4.2a on OS/2. To avoid wasting an SQL user connection between the timed checks, you might want the Close method to release the user connection. However, the Close method doesn't release the user connection. NOTE: You can create Dynaset or Snapshot objects against ODBC databases, but you cannot use the OpenTable method to directly open ODBC tables. Additional VB.INI or <vb_exe_app_name>.INI SettingsThe following additional settings for the VB.INI or <vb_exe_app_name>.INI initialization file are useful for handling ODBC databases and time-outs:Entry for [Debug]:
Entries for [ODBC]:
REFERENCES
"Microsoft Visual Basic for Windows Professional Features Book 2: Additional query words: jet caching
Keywords : kbinterop kbDatabase kbODBC |
Last Reviewed: June 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |