MDAC 2.5 SDK - OLE DB Programmer's Reference
OLE DB Interfaces


 

IErrorInfo

IErrorInfo is defined by Automation; the following describes how the interface is used in OLE DB. IErrorInfo returns information about an error in addition to the return code. It returns the error message, name of the component and GUID of the interface in which the error occurred, and the name and topic of the Help file that applies to the error.

When to Implement

IErrorInfo is implemented by code in the Microsoft® Data Access Components (MDAC) SDK. This code calls provider-specific code in IErrorLookup to retrieve error messages, sources, and Help file information.

OLE DB error objects expose IErrorInfo at two levels. First, it is exposed on the OLE DB error object itself, which enables Automation consumers to use OLE DB error objects. The interface pointer is returned by IErrorRecords::GetErrorInfo in the Automation DLL; it can also be returned by QueryInterface. IErrorInfo returns the information stored in record 0 of the OLE DB error object and uses the default locale ID.

IErrorInfo is also exposed on individual records in the OLE DB error object. These IErrorInfo interface pointers, returned by IErrorRecords::GetErrorInfo, are different from the IErrorInfo interface pointer exposed on the OLE DB error object itself and cannot be returned by QueryInterface. The record to which the interface pointer applies and the locale ID it uses are specified by the consumer in IErrorRecords::GetErrorInfo.

When to Call

Automation consumers call IErrorRecords::GetErrorInfo in the Automation DLL to get an IErrorInfo interface pointer on the OLE DB error object.

OLE DB consumers also call IErrorRecords::GetErrorInfo in the Automation DLL. However, they do not generally use the returned IErrorInfo interface pointer. Instead, they call QueryInterface to get an IErrorRecords interface pointer and then call IErrorRecords::GetErrorInfo to get an IErrorInfo interface pointer on a particular record in the OLE DB error object. Then the OLE DB consumers use this interface pointer to retrieve the error information.

Method Description
GetDescription Returns a text description of the error.
GetGUID Returns the GUID of the interface that defined the error.
GetHelpContext Returns the Help context ID for the error.
GetHelpFile Returns the path of the Help file that describes the error.
GetSource Returns the name of the component that generated the error, such as "ODBC driver-name".