From Inside ODBC, Ch. 5
A connection handle manages all information about a connection. From a
driver writers perspective, this means that a connection handle is used to
keep track of a network connection to a server or alternatively to keep
track of directory and file information if the local file system is the
source of data.
From the Driver Managers perspective, a connection handle is used to
identify the driver used in the connection and for all routing of function
calls. Using the Windows naming scheme, a connection handle is referred to
as an hdbc (handle to a database connection).
An hdbc is allocated with a function call that associates it with the
environment handle: SQLAllocConnect(henv, &hdbc). It is deallocated with the
SQLFreeConnect function. The Driver Manager stores the hdbc inside the data
structure referenced by the henv. In fact, because multiple connection
handles can be allocated, the Driver Manager actually keeps a list of
connection handles associated with the environment handle.
After the hdbc is allocated, it can be used to make a connection. The
connection handle stores the array of function pointers for a specific
After the connection function has successfully completed, the driver is
loaded into memory. Now the driver has a connection to the database server
and is ready to process SQL statements. At this point we say the hdbc is in
an active or a connected state, to distinguish it from an hdbc that is in an
Keep in mind that the connection process causes the Driver Manager to pass
to the driver the requests to allocate an environment handle and a
connection handle, so allocation of the drivers environment and connection
handles does not happen at the same time that it happens in the application
but when the application calls SQLConnect or another connection function.
For every ODBC function that is called, the Driver Manager will look up the
corresponding entry point in the array of function pointers stored in the
connection handle and make an indirect call to the driver.
In addition to storing the overall connection context information, a
connection handle is used for the following purposes in the ODBC API:
To establish a connection using SQLConnect, SQLDriverConnect, or
SQLBrowseConnect, and to break the connection using SQLDisconnect.
To pass to SQLError any errors that occur at the connection level, such as
the failure to load a driver, the failure to connect to the server across
the network, all communication errors (for example, network or wide area
network connection drops), the expiration of a connection time-out, the
attempt to use a connection already in use, and so forth.
To set connection options such as time-outs, transaction isolation levels,
and other options that are set using the SQLSetConnectOption function.
As the main transaction management handle. The context of a transaction is
determined by the hdbc. That is, the set of all the statements associated
with an hdbc constitutes the scope of the transaction. Although the
SQLTransact function can be used with an environment handle, as discussed in
the previous section, it is most often used with a connection handle.
As an argument of the informational functions SQLGetInfo and
SQLGetFunctions, which return information about the driver, data source, and
connection associated with the hdbc. A third informational function,
SQLNativeSQL, uses the hdbc to return SQL strings to an application,
translating escape clauses (see section 220.127.116.11) to DBMS-specific syntax and
performing other transformations.
Web Site: http://home.sprynet.com/sprynet/rasanen/
American Express TRS #265349
>I am trying to create a SQL Server transaction using VBScript on an Active
>However, I get the following error message
>"Cannot start transaction because more than one hdbc is in use. "
>Can anyone explain it to me please.
>Thanks in Advance