Version: 7.0.0

SQLSetConnectAttr ​

Function ​

Sets various connection attributes.

Prototype ​

c
SQLRETURN SQLSetConnectAttr(SQLHDBC       ConnectionHandle,
                            SQLINTEGER    Attribute,    
                            SQLPOINTER    ValuePtr,     
                            SQLINTEGER    StringLength);

Parameters ​

Table 1 SQLSetConnectAttr parameters

Keyword

Parameter Description

ConnectionHandle

Connection handle.

Attribute

Connection attribute to be set. It can be one of the following values:

  • SQL_ATTR_AUTOCOMMIT: Enables or disables auto-commit. 1: Enabled; 2: Disabled.
  • SQL_ATTR_QUERY_TIMEOUT: Specifies the maximum wait time for SQL execution, in seconds.
  • SQL_ATTR_LOGIN_TIMEOUT: Specifies the maximum wait time for logging in to the database.
  • SQL_ATTR_CONNECTION_TIMEOUT: Specifies the database connection timeout.

If the specified attribute is not within the above range, the driver returns SQL_ERROR.

ValuePtr

Points to the value of the corresponding attribute. Depending on the attribute value, it can be a 32‑bit unsigned integer value or points to a null‑terminated string.

StringLength

If ValuePtr points to a string or a binary buffer, this parameter is the length of *ValuePtr. If ValuePtr points to an integer value, StringLength is ignored.

Return Values ​

  • SQL_SUCCESS: The call is successful.

  • SQL_SUCCESS_WITH_INFO: Some warning information is present.

  • SQL_ERROR: The connection attribute failed to be set.

  • SQL_INVALID_HANDLE: The input handle is invalid.

Example ​

See: Example