Transaction Directive

Discussion in 'ASP General' started by Eric, Feb 17, 2006.

  1. Eric

    Eric Guest

    I'm trying to determine where within my code I need to place
    'ObjectContext.SetAbort' Here's some pseudocode:
    ------------------------------------------------------

    <%@ TRANSACTION = Required %>
    <% CID = 45
    insert_customer()
    insert_trans (CID)

    sub insert_customer
    Set adoCmd = Server.CreateObject("ADODB.Command")
    adoCmd.CommandText = "sp_addNewCustomerAndAccount"
    adoCmd.ActiveConnection = ADOConnection
    adoCmd.CommandType = adCmdStoredProc
    adoCmd(1) = "Test"
    adoCmd(2)= "xya"
    adoCmd(3) = "chicago"
    adoCmd.Execute
    end sub

    Sub insert_trans (CID)
    Set RS = Server.CreateObject("ADODB.RecordSet")
    adoCmd.ActiveConnection = ADOConnection
    adoCmd.CommandText = "ADDTRANS"
    adoCmd.CommandType = adCmdStoredProc

    adoCmd(1) = CID
    adoCmd(2) = 48.50
    adoCmd(3) = 12
    adoCmd(4) = "title"
    adoCmd.Execute
    check_err ()
    End sub

    sub check_err ()
    If Err.number <> 0 then
    ObjectContext.SetAbort
    End if
    end sub
    %>
    ------------------------------------------------------
    Now I've placed the check_err () at the end of my insert_trans sub because
    if this is unsuccesful, I don't want the customer inserted either. The thing
    is, if I purposely throw an error (within the stored proc, for example), sub
    check_err does not get called. My question is, at what point should I call
    check_err?

    Also, if I remove this sub (and the call to it) altogether, the transaction
    succesfully rolls back if I make it throw an error. I thought '
    ObjectContext.SetAbort' must be somewhere in the code for this to occur?
    Eric, Feb 17, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eitan

    Error in OLEDB Transaction

    Eitan, Apr 6, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    1,952
    Tad Marshall
    Apr 10, 2005
  2. Eitan

    long time transaction

    Eitan, Apr 11, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    585
    Eitan
    Apr 11, 2005
  3. ben cohen
    Replies:
    0
    Views:
    1,087
    ben cohen
    Aug 20, 2003
  4. R Paley
    Replies:
    2
    Views:
    505
    Paul Uiterlinden
    Nov 20, 2004
  5. Vencz Istv?n
    Replies:
    2
    Views:
    284
Loading...

Share This Page