The ERRORINFO structure does not contain the error messages and help file information that IErrorInfo can return. Instead, this information is stored in a provider-specific lookup service. There are several reasons for this. First, it allows the information to be easily localized. Second, it means that the information is not created and passed around until it is requested. Third, it provides an easy mechanism by which the provider can parameterize error messages.
The information in this lookup service can be created when the lookup service is written or it can be created at run time. The former case, known as static errors, is common when the lookup service is tied to a single database and the programmer knows ahead of time what the error messages are. For example, a provider built directly over an Oracle database might use static errors.
The latter case, known as dynamic errors, is common when the lookup service is not tied to any particular database and the programmer cannot predict the error messages. For example, a provider built on top of any ODBC driver might use dynamic errors. The lookup service creates dynamic errors at run time and releases them when the error object with which they are associated calls IErrorLookup::ReleaseErrors as part of its release code. Dynamic errors are identified by a dynamic error ID. In most cases, all dynamic errors associated with a single error object have the same ID. This is not required, but it is more efficient when releasing error objects.
An error lookup service must be created by each provider that supports OLE DB error objects. The lookup service exposes the IErrorLookup interface. For information about the registry entries used by error lookup services, see "Error Lookup Service Registry Entries" in Chapter 14.
When a consumer calls IErrorInfo::GetDescription or IErrorInfo::GetSource for a particular record in an OLE DB error object, the error object creates an instance of the error lookup service. It then calls IErrorLookup::GetErrorDescription and passes the hrError element of the ERRORINFO structure in the record, along with the lookup ID, the locale ID, and the parameters. GetErrorDescription uses the information provided to retrieve the error description and inserts the parameters into this description. However, if the lookup ID is set to IDENTIFIER_SDK_ERROR, the error object bypasses the error lookup service and retrieves the error description from the error resource DLL shipped with the OLE DB SDK. Finally, the error object returns the completed, localized error message and source to the error object, which returns them to the consumer.
A similar process occurs when the consumer calls IErrorInfo::GetHelpFile or IErrorInfo::GetHelpContext, although no parameters are passed. If the lookup ID is set to IDENTIFIER_SDK_ERROR, then the error object uses the error lookup service to get the Help file and Help context ID.