Transaction processing in ASP

xiaoxiao2021-03-06  57

ASP Squadron Database Table Operation (INSERT / UPDATE / DELETE), you can use transaction and multi-transaction processing.

In ASP's Database Object Link Object, provide properties:

BeGintrans business

CommitTrans transaction

RollbackTrans transaction rollback

<%

ON ERROR Resume Next 'After the error occurs, continues to handle the' ASP to use transaction SET conn = server.createObject ("AdoDb.Connection") conn.open "course_ dn", "course_user", "course_password" conn.begintrans' start transaction SQL = "delete from user_info" set = server.createObject ("AdoDb.Recordset") rs.open SQL, CONN, 3, 3 if Conn.Errors.count> 0 Then 'has errors happen conn.rollbacktrans' rollback SET RS = Nothing conn.close set conn = nothing response.write "failed to roll back to the state before the modification!" Response.end else conn.committrans' Submit transaction SET RS = Nothing conn.close set conn = nothing response.write "transaction Success! "Response.end end if%>

In ASP, do not provide the end of the transaction, BeGintrans only acts on their own domain, just like a variable declaration, if Begintrans in the function body, things only act on this function, if BeGintrans is in the function body, the page level, The scope of the transaction begins with BeGintrans, and the end of the page is in the management state of the transaction.

转载请注明原文地址:https://www.9cbs.com/read-109126.html

New Post(0)