OdbcSetEnvAttr Function

Action

Modifies the current value of a specified environment attribute. All environment attributes persist until the environment handle is freed with the OdbcFree function.

Because more than one environment handle can be allocated simultaneously, environment attribute settings on one environment are not affected when another environment is allocated. Once an environment attribute is set, that attribute’s value affects all data source connections that exist or become allocated under the specified environment.

Include file

ODBC.bdh

Syntax

OdbcSetEnvAttr( in hEnvironment : number,
                in nAttribute   : number,
                in sValue       : string): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hEnvironment Environment handle that refers to a previously allocated environment information storage buffer.
nAttribute

Environment attribute of which the value is to be modified. This parameter must be set to one of the following values:

  • SQL_ATTR_CONNECTION_POOLING

  • SQL_ATTR_CP_MATCH

  • SQL_ATTR_ODBC_VERSION

  • SQL_ATTR_OUTPUT_NTS

sValue

New value for the environment attribute nAttribute. The following parameters are allowed:

For nAttribute SQL_ATTR_CONNECTION_POOLING:

  • SQL_CP_OFF

  • SQL_CP_ONE_PER_DRIVER

  • SQL_CP_ONE_PER_HENV

For nAttribute SQL_ATTR_CP_MATCH:

  • SQL_CP_STRICT_MATCH

  • SQL_CP_RELAXED_MATCH

For nAttribute SQL_ATTR_ODBC_VERSION:

  • SQL_OV_ODBC2

  • SQL_OV_ODBC3

For nAttribute SQL_ATTR_OUTPUT_NTS:

  • SQL_TRUE

  • SQL_FALSE

Example

var
  hEnv, hDbc: number;

dcltrans
  transaction TConnect
  begin
    OdbcAlloc(SQL_HANDLE_ENV, hEnv);
    OdbcAlloc(SQL_HANDLE_DBC, hDbc, hEnv);
    OdbcSetEnvAttr(hEnv, SQL_ATTR_CONNECTION_POOLING, SQL_CP_ONE_PER_DRIVER);
    OdbcConnect(hDbc, "DSN=database;UID=user;PWD=pass;");
  end TConnect;