Microsoft Office Tutorials and References
In Depth Information
Tip Clearing the Err
Even though you can’t rely on the Err object for all the details about an error, you can rely
on the Err object to identify that an error has occurred. Just remember to use the Clear
method to remove any previous information in the Err object before you execute your
database request.
The Errors collection object is a typical collection object containing a Count property and an
Item property that returns an Error object. You can use a For…Each loop to process all the
items in the collection, and then use the Clear method to erase all the Error objects in the col­
flection.
Note The Errors collection is populated only when an error occurs. Use the Clear method
before you execute a command to avoid detecting an error that has already been handled.
Using the Error Object
The Error object contains a number of properties that describe a specific error condition.
(See Table 23-4.) For the most part, these properties provide information about the error
from several different perspectives, which might be necessary depending on the exact cause
of the error.
Table 23-4. Key Properties of the Error Object
Property
Description
Description
Contains a short text description of the error.
NativeError
Contains a provider-specific error code.
Number
Contains the OLE DB error code.
SQLState
Contains the standard five-character ANSI SQL error code.
The Command Object
The Command object contains information about the task that the database will run.
Depending on the type of command you want to execute, you might also have to use the
Parameter object and the Parameters collection to execute a stored procedure.
Search JabSto ::




Custom Search