please dont rip this site
Platform SDK: IIS SDK
      [IIS 5.0] [IIS 5.1] [IIS 6.0]

ObjectContext Object

You can use the ObjectContext object to either commit or abort a transaction, managed by Component Services, that has been initiated by a script contained in an ASP page.

When an .asp file contains the @TRANSACTION directive, the page runs in a transaction and does not finish processing until the transaction either succeeds completely or fails.

Syntax

ObjectContext.method

Methods

ObjectContext.SetAbort Declares that the transaction initiated by the script has not completed and that the resources should not be updated.
ObjectContext.SetComplete Declares that the script is not aware of any reason for the transaction not to complete. If all components participating in the transaction also call SetComplete, the transaction completes.

Events

OnTransactionAbort Event
OnTransactionCommit Event

Remarks

The ASP ObjectContext object implements two methods of the COM+ ObjectContext object. The SetAbort method explicitly aborts the transaction. This causes Component Services to prevent any updates to resources that were contacted during the first phase of the transaction. When the transaction aborts, the script's OnTransactionAbort event will be processed.

Calling the SetComplete method does not necessarily mean that the transaction is complete. The transaction will only complete if all of the transactional components called by the script call SetComplete. In most instances, you will not need to call SetComplete within the script, as the script is assumed to be complete if it finishes processing without calling SetAbort.

The COM+ ObjectContext object exposes methods in addition to SetAbort and SetComplete. These other methods are not available to ASP scripts; however, they are available to COM+ components that can be called by the ASP scripts.

Example

The following example uses the SetAbort and SetComplete methods. The first example file, Sales.htm, obtains data required to process a sales request. The second file, SalesVerify.asp, contains a script that uses two objects, Inventory and Sales, to process the sale. SetAbort is called if Inventory returns an error code indicating that there is not sufficient inventory on hand to process the sale. If the Inventory object does not return the error code, SetComplete is called and the sale is processed.

--- Sales.htm ---



<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">



<HTML>

<HEAD>

<TITLE>Sales Order</TITLE>

</HEAD>

<BODY BGCOLOR="#FFFFFF"><FONT FACE="ARIAL,HELVETICA">

<H2>Sales Order Form </H2>



<FORM METHOD=POST ACTION="SalesVerify.asp"> 

<P>Please enter the product code, quantity, and your account number.

<INPUT TYPE=TEXT NAME=QuantityToBuy> 

<INPUT TYPE=TEXT NAME=ProductCode> 

<INPUT TYPE=TEXT NAME=AccountIn> 

<P>

<INPUT TYPE=SUBMIT> 

</FONT> 

</BODY>

</HTML>

--- SalesVerify.asp ---



<%@ Transaction =index.html Required %>

<%

  Set CurrentQOH = Server.CreateObject("Mycomp.Inventory")

  Set CurrentSales = Server.CreateObject("Mycomp.Sales")

 

  CheckQuantity = Request("QuantityToBuy")

  CheckProduct = Request("ProductCode")

  QuantityStatus = CurrentQOH.CheckQOH(CheckQuantity,CheckProduct)

 

  If QuantityStatus = None

    ObjectContext.SetAbort

    Response.Write "Sorry, there is not sufficient quantity on hand to process your sale."

  Else 

    ObjectContext.SetComplete

    Account = Request("AccountIn")

    Saleupdate = CurrentSales.PostIt(AccountIn)

  End If

%>

See Also

Requirements

Platforms: Windows 2000 with IIS 5.0 installed, Windows XP with IIS 5.1 installed, Windows Server 2003 family with IIS 6.0 installed

Platform SDK Release: February 2003
What did you think of this topic?
Order a Platform SDK CD


file: /Techref/language/asp/OBJ/ref_vbom_obco.htm, 6KB, , updated: 2003/5/15 13:13, local time: 2024/12/19 00:07,
TOP NEW HELP FIND: 
3.148.108.152:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/language/asp/OBJ/ref_vbom_obco.htm"> ObjectContext Object</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .