Object Model > Error Object, Errors Collection |
OLE DB data sources can generate more than one error in response to a single failure. Simple providers generate a single error object, but more advanced ones can generate more than one object. This is because a provider can consist of several components and each component may have something to say about the error.
The first (main) error object is generated when an error condition first occurs in one of the provider's components. This is the original source of the error, which is usually used to describe the error. Then components that called it can add their own description of the error. In most cases, only the original (deepest in call stack) error matters, but sometimes users need to examine the whole set (collection) of generated errors. For example, the MS OLE DB provider for SQL Server generates multiple error objects in response to a single failure.
TDBGrid's Error event only shows one error, the original (main) one. This would not be a problem if the user would always have access to the ADO Errors collection in the data source. However, ADO fills its Errors collection only in response to direct calls to ADO methods. For example, the Errors collection will be filled for a failed Recordset.Update call, but it won't be filled on a failed update initiated by the grid.
For this reason, the TDBGrid control (OLE DB version only) maintains its own collection of Error objects to hold information about errors caused by interaction with the grid's OLE DB data source. This collection is accessed using the Errors property.