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.