Skip to content

SQLSetEnvAttr

SQLSetEnvAttr#

SQLSetEnvAttr() sets the environment attribute for the current environment.

Syntax#

SQLRETURN  SQLSetEnvAttr (
    SQLHENV     env,
    SQLINTEGER  Attribute,
    SQLPOINTER  Value,
    SQLINTEGER  StringLength );

Argument#

Data Type Argument In/Output Description
SQLHENV env Input Environment handle
SQLINTEGER Attribute Input Environment attribute to set
SQLPOINTER Value Input Pointer of the value related to the Attribute.
Depending on the Attribute, the Value will be either a 32-bit unsigned integer or a pointer indicating the Nullterminator string
SQLINTEGER StringLength Input In case the attribute is the character, it is the length of *Value.

Return Values#

SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_INVALID_HANDLE
SQL_ERROR

Description#

An application can call SQLSetEnvAttr() only when no connection handle is allocated in the current environment. All environment attribute successfully set in an application are stored till SQLFreeHandle() is called in the current environment.

Environment Attributes#

Attribute Descirption
SQL_ATTR_ODBC_VERSION (Applied only in Win32.)
SQL_OV_ODBC3 or SQL_OV_ODBC2

Diagnosis#

SQLSTATE Description Comments
HY000 General error
SQLAllocHandle