Name

OnTransactionAbort — OnTransactionAbort( )

Synopsis

The OnTransactionAbort event procedure is processed immediately if the SetAbort method of the ObjectContext object is called explicitly in scripted code or by a server component called from the scripted code. If no code calls the SetAbort method, this event procedure is never processed.

Parameters

None

Example

<% 

' The following code procedure is processed when the code in 
' the SetAbort method example is processed.
Sub OnTransactionAbort ( )
%>
   Your book sales transaction could not be completed.
   Either there was not sufficient inventory for your
   sale to be processed, or your credit card did not 
   go through.
<%
   ' Clean up any nontransactional actions here...

End Sub

%>

Notes

Use OnTransactionAbort to clean up any nonsupported actions your transaction makes that must be reversed if the transaction fails. This includes changes to variables (session- and application-level scope), the registry, and the file system. Note, however, that your server components should clean up after themselves.

You also should use the OnTransactionAbort event to inform the client that the transaction has failed.

Do not call the SetAbort or SetCommit methods from the OnTransactionAbort event procedure. Doing so may introduce a loop and result in the loss of function for your application and/or a loss of data.

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.