SQLGetConnectAttr

ODBC and SQL Server

ODBC and SQL Server

SQLGetConnectAttr

The Microsoft® SQL Server™ ODBC driver defines driver-specific connection attributes. Some of the attributes are available to SQLGetConnectAttr, and the function is used to report their current settings. The values reported for these attributes are not guaranteed until after a connection has been made or the attribute has been set using SQLSetConnectAttr.

SQL_COPT_SS_ANSI_NPW

SQL_COPT_SS_ANSI_NPW enables or disables the use of ANSI handling of NULL comparisons, character data type padding, warning levels, and NULL concatenation. For more information, see SET ANSI_NULLS, SET ANSI_PADDING, SET ANSI_WARNINGS, and SET CONCAT_NULL_YIELDS_NULL.

Value Description
SQL_AD_ON Default. The connection uses ANSI default behavior handling NULL comparisons, padding, warnings, and NULL concatenations.
SQL_AD_OFF The connection uses SQL Server defined handling of NULL comparisons, character data type padding, warnings, and NULL concatenations.
SQL_COPT_SS_CONNECTION_DEAD

SQL_COPT_SS_CONNECTION_DEAD reports the alive or dead state of a connection to a server. The driver queries the Net-Library for the current state of the connection.

Value Description
SQL_CD_TRUE The connection to the server has been lost.
SQL_CD_FALSE The connection is open and available for statement processing.

SQL_COPT_SS_PERF_DATA

SQL_COPT_SS_PERF_DATA returns a pointer to a SQLPERF structure containing the current driver performance statistics. SQLGetConnectAttr will return NULL if performance logging is not enabled. The statistics in the SQLPERF structure are not dynamically updated by the driver. Call SQLGetConnectAttr each time the performance statistics need to be refreshed. For more information about performance logging, see SQLSetConnectAttr.

Value Description
NULL Performance logging is not enabled.
Any other value A pointer to a SQLPERF structure.

SQL_COPT_SS_PERF_QUERY

SQL_COPT_SS_PERF_QUERY returns TRUE if logging of long running queries is enabled. The request returns FALSE if query logging is not active.

SQL_COPT_SS_PRESERVE_CURSORS

SQL_COPT_SS_PRESERVE_CURSORS defines the behavior of cursors when manual-commit mode is used. The behavior is exposed as transactions and are either committed or rolled back using SQLEndTran.

Value Description
SQL_PC_OFF Default. Cursors are closed on SQLEndTran.
SQL_PC_ON Cursors remain open after the call to SQLEndTran.

SQL_COPT_SS_QUOTED_IDENT

SQL_COPT_SS_QUOTED_IDENT allows quoted identifiers in ODBC and Transact-SQL statements submitted on the connection. By supplying quoted identifiers, the SQL Server ODBC driver allows otherwise invalid object names such as "My Table," which contains a space character in the identifier.

Value Description
SQL_QI_OFF The SQL Server connection does not allow quoted identifiers in submitted Transact-SQL.
SQL_QI_ON Default. The connection allows quoted identifiers in Transact-SQL submitted.

SQL_COPT_SS_TRANSLATE

SQL_COPT_SS_TRANSLATE controls character translation as MBCS data is exchanged. The attribute affects only data stored in SQL Server char, varchar, and text columns.

Value Description
SQL_XL_OFF The SQL Server ODBC driver does not translate characters from one code page to another in character data exchanged between the client and the server.
SQL_XL_ON Default. The SQL Server ODBC driver translates characters from one code page to another in character data exchanged between the client and the server. The driver automatically configures the character translation, determining the code page installed on the server and that in use by the client.

SQL_COPT_SS_USE_PROC_FOR_PREP

This option is valid only when connected to SQL Server version 6.5 or earlier. SQL_COPT_SS_USE_PROC_FOR_PREP defines the use of temporary stored procedures when ODBC and Transact-SQL statements are prepared for execution. For more information about prepared statement execution, see SQLPrepare.

Value Description
SQL_UP_OFF The driver does not generate stored procedures when the application prepares statements.
SQL_UP_ON Default. The driver generates a temporary stored procedure when a statement is prepared. The stored procedure is dropped when the application disconnects from the server.
SQL_UP_ON_DROP The driver generates a temporary stored procedure when a statement is prepared. The stored procedure is dropped when the statement handle is freed.

SQL_COPT_SS_USER_DATA

SQL_COPT_SS_USER_DATA retrieves the user-data pointer. User data is stored in client-owned memory and recorded per connection. If the user-data pointer has not been set, SQL_UD_NOTSET, a NULL pointer, is returned.

Value Description
SQL_UD_NOTSET No user-data pointer is set.
Any other value A pointer to the user data.

See Also

Delimited Identifiers

SET ANSI_NULLS

SET ANSI_PADDING

SET ANSI_WARNINGS

SQLEndTran