How to make good use of Transaction in the database?
In the actual operation of ASP, such a situation always occurs, such as transferring money from my account to Fei Wenhua's account at the bank.
My account showed that it had been debited, but due to the bank's system failure, the database change of Fei Wenhua's account failed.
How should this be handled? There should be no loss of the amount in my account, right?
Of course, your interests will not be lost, and the changed account database information will be automatically restored.
What is used here is the interactive function (TRANSACTION), which is composed of IIS and MTS (Microsoft Transaction Server)
Done together. Its function is: when all database changes in the ASP program are successful, it is considered successful; if one of them
If a database change fails, other changed database records will be automatically restored.
Both SQL SERVER and ORACLE databases provide interactive functions, but ACCESS does not.
This interactive function works within the scope of an ASP program, that is to say, all databases involved in this program have interactive functions.
The method is to add: in the first line of the ASP program:
TRANSACTION=Required
To tell IIS that this program wants to use interactive functions, the specific ASP program:
< %@ TRANSACTION=Required LANGUAGE=VBScript% >
…
< % Set obj1 = Server.CreateObject(testobj.cls1)% >
< % = obj1.data3t(1,10)% >
<%
SubOnTransactionCommit()
…
End Sub
SubOnTransactionAbort()
…
End Sub
%>