SQLAllocConnect
Full Description
swirl
Syntax
  define external counter function SQLAllocConnect
     (  read-only SQL_handle_type EnvironmentHandle,
        read-only SQL_handle_type ConnectionHandle )


Purpose

Allocates an SQL connection handle within the environment identified by EnvironmentHandle. This function has been superseded by SQLAllocHandle in ODBC 3.0.

Input arguments:

  • EnvironmentHandle.
  • ConnectionHandle.

The following code demonstrates how to use SQLAllocConnect to allocate a connection handle within the identified environment.

  local SQL_Handle_type EnvironmentHandle
  local SQL_Handle_type ConnectionHandle
  local SQL_Vector_type Vector
  local counter CounterSizeInBytes initial {4}
  local counter RetCode

  set RetCode to SQLAllocHandle
        ( SQL_HANDLE_ENV, SQL_NULL_HANDLE, EnvironmentHandle )
  output "Allocating environment handle - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  SQLSetVectorSize( Vector, CounterSizeInBytes )
  SQLSetVectorAsCounter( Vector, SQL_OV_ODBC2 )
  set RetCode to SQLSetEnvAttr
        (  EnvironmentHandle,
           SQL_ATTR_ODBC_VERSION,
           Vector,
           CounterSizeInBytes,
           SQL_INTEGER )
  output "Setting environment attribute - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLAllocConnect(EnvironmentHandle, ConnectionHandle)
  output "Allocating connection handle - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLFreeConnect(ConnectionHandle)
  output "Freeing connection handle resources - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLFreeEnv(EnvironmentHandle)
  output "Freeing environment handle resources - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

Copyright © OmniMark Technologies Corporation, 1988-1998.