Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » SQL Anywhere ODBC API » ODBC handles

ODBC handles Next Page

Allocating ODBC handles


The handle types required for ODBC programs are as follows:

Item Handle type
Environment SQLHENV
Connection SQLHDBC
Statement SQLHSTMT
Descriptor SQLHDESC
To use an ODBC handle
  1. Call the SQLAllocHandle function.

    SQLAllocHandle takes the following parameters:

  2. Use the handle in subsequent function calls.

  3. Free the object using SQLFreeHandle.

    SQLFreeHandle takes the following parameters:

Example

The following code fragment allocates and frees an environment handle:

SQLHENV env;
SQLRETURN retcode;
retcode = SQLAllocHandle( 
      SQL_HANDLE_ENV, 
      SQL_NULL_HANDLE, 
      &env ); 
if( retcode == SQL_SUCCESS 
    || retcode == SQL_SUCCESS_WITH_INFO ) {
  // success: application Code here
}
SQLFreeHandle( SQL_HANDLE_ENV, env );

For more information about return codes and error handling, see Handling errors.