Application of transaction techniques in ASP

Source: Internet
Author: User
A business is a series of operations that must be successful, and if one step fails, the other steps must be undone. In fact, in the database system, each SQL statement is a transaction, when executing this statement, either executes successfully, or executes the error and exits to the initial state. However, if you perform a set of SQL statements, you cannot revert to the original state when one of the steps fails, and you need to use the transaction processing mechanism to handle it.

ASP built-in components of the connection object, the main use of the transaction processing method has the following 3:
BeginTrans: For starting a transaction
CommitTrans: For completing/submitting a transaction
RollbackTrans: Rolling back
A simple example:
Copy Code code as follows:

On Error Resume Next
Objconn.begintrans ' Affairs started
More than one SQL statement
If Objconn.errors.count=0 Then
Objconn.committrans ' If there are no errors, execute transaction commits
Else
Objconn.rollbacktrans ' or 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.