SQLGetConnectAttr

The SQL Native Client 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

The SQL_COPT_SS_ANSI_NPW attribute 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

The SQL_COPT_SS_CONNECTION_DEAD attribute reports the 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_FAILOVER_PARTNER

The SQL_COPT_SS_FAILOVER_PARTNER attribute is used to retrieve the name of the failover partner used for database mirroring in SQL Server 2005, and it is a null terminated character string that must be set using SQLSetConnectAttr before the connection to SQL Server is initially made.

After making the connection, the application can query this attribute to determine the identity of the failover partner. If the primary server has no failover partner this property will return an empty string. This allows a smart application to cache the most recently determined backup server, but such applications should be aware that the information is only updated when the connection is first established, or reset, if pooled, and can become out of date for long term connections.

SQL_COPT_SS_PERF_DATA

The SQL_COPT_SS_PERF_DATA attribute 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.

Value Description

NULL

Performance logging is not enabled.

Any other value

A pointer to a SQLPERF structure.

SQL_COPT_SS_PERF_QUERY

The SQL_COPT_SS_PERF_QUERY attribute 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

This attribute allows you to query and set whether or not the connection will preserve the cursor(s) when you commit/rollback a transaction. The setting is either SQL_PC_ON or SQL_PC_OFF. The default value is SQL_PC_OFF. This setting controls whether or not the driver will close the cursor(s) for you when you call SQLEndTran (or SQLTransact).

Value Description

SQL_PC_OFF

Default. Cursors are closed when transaction is committed or rolled back using SQLEndTran.

SQL_PC_ON

Cursors are not closed when transaction is committed or rolled back using SQLEndTran, except when using a static or keyset cursor in asynchronous mode. If a rollback is issued while the population of the cursor is not complete, the cursor is closed.

SQL_COPT_SS_QUOTED_IDENT

The SQL_COPT_SS_QUOTED_IDENT attribute allows quoted identifiers in ODBC and Transact-SQL statements submitted on the connection. By supplying quoted identifiers, the SQL Native Client 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

The SQL_COPT_SS_TRANSLATE attribute 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 Native Client 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 Native Client 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_TRUST_SERVER_CERTIFICATE

The SQL_COPT_SS_TRUST_SERVER_CERTIFICATE attribute causes the driver to enable or disable certificate validation when using encryption. This attribute is a read/write value, but setting it after a connection has been established has no effect.

Client applications can query this property after a connection has been opened to determine the actual encryption and validation settings in use.

Value Description

SQL_TRUST_SERVER_CERTIFICATE_NO

Default. Encryption without certificate validation is not enabled.

SQL_TRUST_SERVER_CERTIFICATE_YES

Encryption without certificate validation is enabled.

SQL_COPT_SS_USE_PROC_FOR_PREP

The SQL_COPT_SS_USE_PROC_FOR_PREP attribute is no longer supported because SQL Native Client does not support connecting to SQL Server 6.5.

SQL_COPT_SS_USER_DATA

The SQL_COPT_SS_USER_DATA attribute 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.

Siehe auch

Konzepte

ODBC API Implementation Details

Andere Ressourcen

Begrenzte Bezeichner (Datenbankmodul)
SET ANSI_NULLS (Transact-SQL)
SET ANSI_PADDING (Transact-SQL)
SET ANSI_WARNINGS (Transact-SQL)
SQLGetConnectAttr Function

Hilfe und Informationen

Informationsquellen für SQL Server 2005