Share via


ISQLErrorInfo::GetSQLInfo

Returns the SQLSTATE and native error code associated with an error.

Syntax

HRESULT GetSQLInfo (
   BSTR    *pbstrSQLState,
   LONG    *plNativeError);

Parameters

  • pbstrSQLState
    [out] A pointer to memory in which to return a pointer to a string that contains the SQLSTATE. An SQLSTATE is a 5-character string defined by the ANSI SQL standard. The memory for this string is allocated by the provider and must be freed by the consumer with a call to SysFreeString. If an error occurs, *pbstrSQLState is set to a null pointer.

  • plNativeError
    [out] A pointer to memory in which to return a provider-specific, native error code. *plNativeError is not necessarily the same as the dwMinor element in the ERRORINFO structure returned by IErrorRecords::GetErrorInfo. The combination of the hrError and dwMinor elements of the ERRORINFO structure is used to identify an error to the error lookup service, whereas *plNativeError has no such restrictions.

Return Code

  • S_OK
    The method succeeded.

  • E_FAIL
    A provider-specific error occurred.

  • E_INVALIDARG
    pbstrSQLState or plNativeError was a null pointer.

  • E_OUTOFMEMORY
    The provider was unable to allocate sufficient memory in which to return the SQLSTATE.