ODBC Error Message Format

ODBC drivers return messages to applications as diagnostic records. An application can call the SQLGetDiagRec and SQLGetDiagField functions to retrieve these diagnostic records. The Microsoft® SQL Server™ ODBC driver maps SQL Server message parts into these standard ODBC diagnostic record fields:

SQLSTATE .
The ODBC specification defines a set of five-character codes called SQLSTATE codes that identify the conditions generating the message. These SQLSTATE codes are not related to any of the parts of a SQL Server message. The SQL Server ODBC driver generates the appropriate SQLSTATE code anytime it returns a message to an application.
pfNative
The SQL Server ODBC driver returns the SQL Server error number as the ODBC pfNative field. For example, if a statement raises a SQL Server error 170 (syntax error), the ODBC driver returns 170 in pfNative.
MessageText
The SQL Server ODBC driver returns the SQL Server error description as the MessageText field in an ODBC diagnostic record. The ODBC specification defines a series of headers for the MessageText field that indicates the component that issued the message:

The ODBC specification allows ODBC drivers to define driver-specific fields in ODBC diagnostic records. The SQL Server ODBC driver maps SQL Server message parts into these SQL Server ODBC driver-specific diagnostic fields:

SQL_DIAG_SS_SEVERITY.
Contains the SQL Server severity level.
SQL_DIAG_SS_MSGSTATE.
Contains the SQL Server state. It is not related to the ODBC SQLSTATE code.
SQL_DIAG_SS_LINE.
Contains the number of the line containing the SQL statement generating the message.
SQL_DIAG_SS_PROCNAME.
Contains the name of the stored procedure generating the message, if appropriate.
SQL_DIAG_SS_SRVNAME.
Contains the name of the server from which the message came.
See Also

Handling Errors and Messages

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.