Class Error (ADODB VBA)
Contains details about data access errors that pertain to a single operation involving the provider. To use a Error class variable it first needs to be instantiated, for example
Description
Describes an Error object.
Use the Description property to obtain a short description of the error. Display this property to alert the user to an error that you cannot or do not want to handle. The string will come from either ADO or a provider. Providers are responsible for passing specific error text to ADO. ADO adds an Error object to the Errors collection for each provider error or warning it receives. Enumerate the Errors collection to trace the errors that the provider passes.
HelpContext
Indicates the Help file and topic associated with an Error object.
If a Help file is specified in the HelpFile property, the HelpContext property is used to automatically display the Help topic it identifies. If there is no relevant help topic available, the HelpContext property returns zero and the HelpFile property returns a zero-length string ("").
HelpFile
Indicates the Help file and topic associated with an Error object.
If a Help file is specified in the HelpFile property, the HelpContext property is used to automatically display the Help topic it identifies. If there is no relevant help topic available, the HelpContext property returns zero and the HelpFile property returns a zero-length string ("").
NativeError
Indicates the provider-specific error code for a given Error object.
Use the NativeError property to retrieve the database-specific error information for a particular Error object. For example, when using the Microsoft ODBC Provider for OLE DB with a Microsoft SQL Server database, native error codes that originate from SQL Server pass through ODBC and the ODBC Provider to the ADO NativeError property.
Number
Indicates the number that uniquely identifies an Error object.
Use the Number property to determine which error occurred. The value of the property is a unique number that corresponds to the error condition. The Errors collection returns an HRESULT in either hexadecimal format (for example, 0x80004005) or long value (for example, 2147467259). These HRESULTs can be raised by underlying components, such as OLE DB or even OLE itself. For more information about these numbers, see Chapter 16 of the OLE DB Programmer's Reference.
Source
Indicates the name of the object or application that originally generated an error.
Use the Source property on an Error object to determine the name of the object or application that originally generated an error. This could be the object's class name or programmatic ID. For errors in ADO, the property value will be ADODB.ObjectName, where ObjectName is the name of the object that triggered the error. For ADOX and ADO MD, the value will be ADOX.ObjectName and ADOMD.ObjectName, respectively. Based on the error documentation from the Source, Number, and Description properties of Error objects, you can write code that will handle the error appropriately. The Source property is read-only for Error objects.
SQLState
Indicates the SQL state for a given Error object.
Use the SQLState property to read the five-character error code that the provider returns when an error occurs during the processing of an SQL statement. For example, when using the Microsoft OLE DB Provider for ODBC with a Microsoft SQL Server database, SQL state error codes originate from ODBC, based either on errors specific to ODBC or on errors that originate from Microsoft SQL Server, and are then mapped to ODBC errors. These error codes are documented in the ANSI SQL standard, but may be implemented differently by different data sources.