Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
ObjectContext Object
All Objects
All Methods
METHOD: ObjectContext.SetAbort
ObjectContext.
SetAbort
The
SetAbort
method explicity declares that a transaction has not been completed and prevents resources from being updated.
If it exists, the
OnTransactionAbort
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 = Request.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") < Request.Form("Order") Then
Response.Write "There is not enough in stock to give the present order. There are " & rsProductSrch.Fields("Quanity") & "in stock and your order is for " & Request.Form("Order") & ".<br>"
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 no quantity of the desired product.
Output:
The transaction aborted because there was not enough quantity on hand to fill your order.
There is not enough of the desired product.
Output:
There is not enough in stock to give the present order. There are 20 in stock and your order is for 25.
The transaction aborted because there was not enough quantity on hand to fill your order.
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information