SQLOLEDB defines the provider-specific error interface ISQLServerErrorInfo. The interface returns more detail about a SQL Server error and is valuable when command execution or rowset operations fail.
ISQLServerErrorInfo is available on the SQLOLEDB implementation of ISQLErrorInfo. Unlike ISQLErrorInfo, the interface is not defined as a custom error object. The consumer queries ISQLErrorInfo to obtain an ISQLServerErrorInfo reference.
The ISQLServerErrorInfo interface exposes one member function GetErrorInfo. The function returns a pointer to an SSERRORINFO structure and a pointer to a string buffer. Both pointers reference memory the consumer must deallocate by using IMalloc::Free.
SSERRORINFO structure members are interpreted by the consumer as follows.
Member | Description |
pwszMessage | SQL Server error message. Identical to the string returned in IErrorInfo::GetDescription. |
pwszServer | The name of the session’s SQL Server. |
pwszProcedure | If appropriate, the name of the procedure in which the error originated. An empty string otherwise. |
lNative | The SQL Server native error number. Identical to the value returned in the plNativeError parameter of ISQLErrorInfo::GetSQLInfo. |
bState | The state of a SQL Server error message. |
bClass | The severity of a SQL Server error message. For more information, see RAISERROR. |
wLineNumber | When applicable, the line number of a stored procedure on which the error occurred. |