Allocating a Connection Handle
1 The application declares a variable of type SQLHDBC. It then calls SQLAllocHandle and passes the address of this variable, the handle of the environment in
which to allocate the connection, and the SQL_HANDLE_DBC option. For example:
SQLAllocHandle(SQL_HANDLE_DBC, henv1, &hdbc1);
The Driver Manager does not call SQLAllocHandle in the driver at this time, as it does not know which driver to call. It
delays calling SQLAllocHandle in the driver until the application calls a function to connect to a data
source. For more information, see
It is important to note that allocating a connection handle is not the same as
loading a driver. The driver is not loaded until a connection function is
called. Thus, after allocating a connection handle and before connecting to the
driver or data source, the only functions the application can call with the
connection handle are SQLSetConnectAttr, SQLGetConnectAttr, or SQLGetInfo with the SQL_ODBC_VER option. Calling other functions with the connection
handle, such as SQLEndTran, returns SQLSTATE 08003 (Connection not open). For complete details, see
Appendix B,