Version: 7.0.0

SQLAllocConnect ​

Function ​

Allocates a connection handle. It can be replaced with SQLAllocHandle.

Prototype ​

c
SQLRETURN SQLAllocConnect(SQLHENV     EnvironmentHandle,    
                          SQLHDBC     *ConnectionHandle);

Parameters ​

Table 1 SQLAllocConnect parameters

Keyword

Parameter Description

EnvironmentHandle

A valid environment handle, which must have been successfully allocated by SQLAllocEnv or SQLAllocHandle.

The environment handle must be allocated before the connection handle, as the connection handle depends on the environment handle.

ConnectionHandle

A pointer to a variable of type SQLHDBC. Upon successful function execution, this variable stores the newly allocated connection handle, which will be used by subsequent functions such as SQLConnect and SQLDisconnect.

Return Values ​

  • SQL_SUCCESS: The call is successful.

  • SQL_SUCCESS_WITH_INFO: Some warning information is present.

  • SQL_ERROR: The connection handle failed to be allocated.

  • SQL_INVALID_HANDLE: The input handle is invalid.

NOTE ​

To make the code more robust and easier to maintain, it is recommended to use the standard interface SQLAllocHandle instead of SQLAllocConnect.

Example ​

See: Example