Logo Head Picture  free e- mail 
 thaimail 
 hotmail 
 yahoo 
 siam2you 
 thammasat
 Home  Visual Basic Active Server Page  JavaScript   Network   Other 
 Active Server Pages.











METHOD:  ObjectContext.SetComplete

ObjectContext.SetComplete

The SetComplete method declares that the transaction of this object has been completed. In order for a transaction to be successfully completed, all individual components of the transaction must also be completed and have called SetComplete. By default, a script is considered to be completed if it runs to conclusion and does not abort. Therefore, in many cases, it may not be necessary to call SetComplete from the script.

If it exists, the OnTransactionCommit event is processed.

Code:
------------------------File1.asp-------------------
<HTML>
<HEAD>
</HEAD>
<BODY>
<form action="File2.asp" method="POST">
ProductID:<input type="Text" name="ProductID">
Product Name:<input type="Text" name="Name">
Quantity Wanted:<input type="Text" name="Order">
<input type="Submit" name="Submit" value="Submit">
</form>
</BODY>
</HTML>
 
------------------------File2.asp-------------------
<%
@Transaction = "Required"
set connDB=server.createobject("adodb.connection")
connDB.Open "products", "", ""
productID = Response.Form("ProductID")
mySQL="Select * from products Where productID = " & productID
Set rsProductSrch = Server.CreateObject("ADODB.Recordset")
rsProductSrch.Open mySQL, connDB, adOpenStatic, adLockPessimistic
If rsProductSrch.BOF Or rsProductSrch.EOF Then
    ObjectContext.SetAbort
ElseIf rsProductSrch.Fields("Quanity") < Response.Form("Order") Then
    Response.Write "There is not enough in stock to give the present order. There are " & rsProductSrch.Fields("Quanity") & "."
    ObjectContext.SetAbort
Else
    rsProductSrch.Fields("Quanity") = rsProductSrch.Fields("Quanity") -
            Request.Form("Order")
    rsProductSrch.Update
    ObjectContext.SetComplete
End If
rsProductSrch.Close
connDB.Close
%>
 
Sub OnTransactionAborted()
Response.Write "The transaction aborted because there was not enough quantity on hand to fill your order."
End Sub
 
Sub OnTransactionCommit()
Response.Write "The transaction was committed and your order is being sent."
End Sub

There is enough to fill the order.
Output:
The transaction was committed and your order is being sent.

Copyright 2000 by Infinite Software Solutions, Inc.
Trademark Information

ASP - Link
ASP reference   
B   
C   
D   
E   
F   
G   
Last update: Copyright © 2001.Memo Wil@keo everything that I like Co.,Ltd.