
January 7th, 2004, 08:17 AM
|
|
Junior Member
|
|
Join Date: Jan 2004
Location: Ark.
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Transactions AND ASP (Not .NET)
I have three tables I am preforming UPDATES On I need to use transactions because if a write fails for some reason on table three the previous two writes need to be rolled back Right now my code is like the following.
Code:
<%
On Error Resume Next
set jc =server.CreateObject("ADODB.CONNECTION")
jc.Open Application("My_ConnectionString")
SQL = "Select * from OwnerTable where OwnerAcctNum = '" & Session("OwnerAcctNum") & "'"
rc.CursorType = adOpenStatic
rc.LockType = adLockOptimistic
jc.BeginTrans
rc.Open SQL, jc
if rc.Fields("BusinessName") <> Request.Form("BBBusName") then
changedFieldCount = changedFieldCount + 1
rc.Fields("BusinessName") = Request.Form("BBBusName")
end if
{....}
The above if routine happens for each field we end up with a field changed count of 3 which is correct then finally the update method is called
{.....}
rc.update
%>
Then the ERROR Code
Code:
{....}
If Err.Number <> 0 Then
Response.Write " Err.Description: " & Err.description & "<br>" &_
"Err.HelpContext: " & Err.HelpContext & "<br>" & _
" Err.Number: " & Err.Number & "<br>" & _
" Err.Source: " & Err.Source & "<br>"
printErrorMessage(Err.Number)
jc.RollbackTrans
End If
{....}
Then I update the next table. How can i preforme the above and use Transactions?
Thanks
Jon {The Intern Fro Hell}
Last edited by pabloj : January 7th, 2004 at 03:36 PM.
|