Operation of database tables in ASP, using transaction processing and support for multi-transaction processing

Source: Internet
Author: User
Transaction Processing | data | database

In the ASP's database object linked object, the properties are provided:

BeginTrans Transaction Start
CommitTrans Transaction Submission
RollbackTrans transaction Rollback
<%
On Error Resume Next ' error occurs after processing
' Using Transactions in ASP '
Set conn=server.createobject ("ADODB. Connection ")
Conn. Open "Course_dsn", "Course_user", "Course_password"
Conn.begintrans ' Start a transaction
Sql= "Delete from User_info"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,conn,3,3
If Conn.errors.count>0 then ' has an error occurred
Conn.rollbacktrans ' Roll back
Set rs=nothing
Conn.close
Set conn=nothing
Response.Write "Transaction failure, roll back to the state before the change!" "
Response.End
Else
Conn.committrans ' commits the transaction
Set rs=nothing
Conn.close
Set conn=nothing
Response.Write "Trading Success! "
Response.End
End If
%>

In the ASP, do not provide the end of the transaction, BeginTrans only for their own domain, similar to the variable declaration, if in the function body BeginTrans, then the object is used only for this function body, if BeginTrans in the function body, in the page level, The scope of the transaction begins at BeginTrans, and the end of the page is in the managed state of the transaction.



Related Article

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.