ISQLServerErrorInfo::GetErrorInfo

Returns a pointer to a SQLOLEDB SSERRORINFO structure containing SQL Server error detail.

HRESULT GetErrorInfo(
SSERRORINFO**ppSSErrorInfo,
OLECHAR**ppErrorStrings);

Arguments

ppErrorInfo [out]
Is a pointer to a pointer to an SSERRORINFO structure.

ppErrorStrings [out]
Is a pointer to a Unicode character-string pointer.

Return Code

S_OK
The method succeeded.

E_INVALIDARG
Either ppSSErrorInfo or ppErrorStrings was NULL.

E_OUTOFMEMORY
SQLOLEDB was unable to allocate sufficient memory to complete the request.

Comments

SQLOLEDB allocates memory for the SSERRORINFO and OLECHAR strings returned through the pointers passed by the consumer. The consumer must deallocate this memory by using IMalloc::Free when it no longer requires access to the error data.

The SSERRORINFO structure is defined as follows:

typedef struct tagSSErrorInfo
{
LPOLESTR pwszMessage;
LPOLESTR pwszServer;
LPOLESTR pwszProcedure;
LONG lNative;
BYTE bState;
BYTE bClass;
WORD wLineNumber;
}
SSERRORINFO;
  
Member Description
PwszMessage The error message from SQL Server. The message is returned through IErrorInfo::GetDescription.
PwszServer The name of the SQL Server on which the error occurred.
PwszProcedure The name of the stored procedure generating the error if the error occurred in a stored procedure. Otherwise, an empty string.
LNative The SQL Server error number. The error number is identical to that returned in the plNativeError parameter of ISQLErrorInfo::GetSQLInfo.
BState The state of a SQL Server error. For more information, see RAISERROR.
BClass The severity of a SQL Server error. For more information, see RAISERROR.
WLineNumber When applicable, the line of a SQL Server stored procedure that generated the error message.

Pointers in the structure reference addresses in the string returned in ppErrorStrings.