ASP 3.0 advanced programming (40)

Source: Internet
Author: User
8.5.1 Errors set
The Errors set contains the Error object of every Error caused by the execution of a single ADO command. The reason for using the Errors set is that multiple Errors may occur during the execution of a command. The ole db provider must provide a way to notify the customer that multiple Errors have occurred.
There are two important points about the Errors set:
· Every time you run the ADO command, if an error occurs, the error set will be cleared, and new error content will be generated at the same time. Of course, if no error occurs, the Errors set will not be affected. Therefore, even if the ADO command is successfully executed, this set may contain error messages.
· The ole db provider may load messages or warnings containing information into the Errors set with the error code 0. Therefore, you cannot only check the error numbers in the set and assume that the error has occurred. For example, if you use an ODBC provider to connect to SQL Server, you may get an "error" notifying you that the default database has changed.
If you look back at the object model mentioned in this chapter, you may find that the Errors set can only be accessed by the Connection object. Readers may wonder how to access the Errors set without explicitly creating a Connection object? The Recordset object has an ActiveConnection attribute that contains the Connection object of the current record set. This means that the Errors set can be obtained as follows:
RsAuthors. ActiveConnection. Errors
To view all Errors, traverse the entire Errors set:
For Each errAuthors In rsAuthors. ActiveConnection. Errors
'Display error
Next
To display some reasonable error information, you need to know exactly what is in the Errors collection.
The Error object contains the attributes shown in Table 8-5:
Table 8-5 attributes and descriptions of Error objects
Genus
Description
Number
ADO error code
NativeError
Error code obtained from the data provider
SQLState
Five-digit SQL status code when connecting to the SQL database
Source
Error object
Description
Error description text
This means that the loop process can now become like this:
For Each errAuthors In rsAuthors. ActiveConnection. Errors
Response. Write "Number:" & errAuthors. Number &_
"<BR> NativeError:" & errAuthors. NativeError &_
"<BR> SQLState:" & errAuthors. SQLState &_
"<BR> Source:" & errAuthors. Source &_
"<BR> Description:" & errAuthors. Description &_
"<P>"
Next
8.5.2 ADO error in ASP page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.