Asp built-in objectObjectContext detailed explanation
You can use the ObjectContext object to submit or abandon a transaction managed by Microsoft TransactionServer (MTS), which is initialized by scripts contained in the ASP page.
When the ASP contains the @TRANSACTION directive, the page runs in the transaction and does not terminate until the transaction succeeds or fails.
grammar
ObjectContext.method
method
The SetCompleteSetComplete method declares that the script does not understand the reason why the transaction is not completed. If all components in the transaction call SetComplete, the transaction will complete.
The SetAbortSetAbort method declares that the transaction initialized by the script has not completed and the source cannot be updated.
event
OnTransactionCommit
OnTransactionAbort
Comments
ObjectContext implements two methods of MTSObjectContext object. The SetAbort method terminates the transaction completely. In this way, the MTS does not update the source of the contact in the first phase. When the transaction terminates, the OnTransactionAbort event of the script will be processed.
Calling the SetComplete method does not necessarily mean that the transaction has been completed. The transaction can only be completed if all transaction components called by the script call SetComplete. In most instances, if SetAbort is not called at the end of processing, the script is usually assumed to be completed, so SetComplete is not necessarily called within the script.
ObjectContext shows six methods other than SetAbort and SetComplete. These methods can be used for components called by scripts, but cannot be used directly with ASP scripts.
Example
Here is a demonstration of the method using SetAbort and SetCommit. The Sales.htm file gets the data needed to process sales requests. The script in the second file, SalesVerify.asp, uses two objects, Inventory and Sales, to handle sales. If Inventory returns an error code that indicates insufficient inventory for sale, SetAbort will be called. If the Inventory object does not return an error code, SetComplete will be called to process the sales request.
Sales.htm
<!DOCTYPEHTMLPUBLIC"-//IETF//DTDHTML//EN">
<HTML>
<HEAD>
<TITLE>SalesOrder</TITLE>
</HEAD>
<BODYBGCOLOR="#FFFFFF"><FONTFACE="ARIAL,HELVETICA">
<H2>SalesOrderForm</H2>
<FORMMETHOD=POSTACTION="SalesVerify.asp">
<P>Pleaseentertheproductcode,quantity,andyouraccountnumber.
<INPUTTYPE=TEXTNAME=QuantityToBuy>
<INPUTTYPE=TEXTNAME=ProductCode>
<INPUTTYPE=TEXTNAME=AccountIn>
<P>
<INPUTTYPE=SUBMIT>
</FONT>
</BODY>
</HTML>
SalesVerify.asp file
<%@Transaction=Required%>