Transaction Directive

E

Eric

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top