Application transaction processing skills in ASP

Source: Internet
Author: User

A transaction is a series of operations that must be successful. If one operation fails, other steps must be undone. In fact, in the database system, each SQL statement is a transaction. When this statement is executed, it is either executed successfully, or an error is executed and exited to the initial state. However, if you execute a group of SQL statements, when one of the steps fails, it cannot be restored to the initial state. At this time, you need to use the transaction processor mechanism for processing.

The connection object in the ASP built-in component mainly uses the following three methods for transaction processing:
Begintrans: Used to start a transaction
Committrans: Used to complete/commit a transaction
Rollbacktrans: rollback
A simple example:CopyCodeThe Code is as follows: on error resume next
Objconn. begintrans 'transaction start
Multiple SQL statements
If objconn. errors. Count = 0 then
Objconn. committrans: If no error occurs, the transaction is committed.
Else
Objconn. rollbacktrans 'otherwise, roll back
End if

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.