beginTrans without commitTrans or rollbackTrans
From: bucket79 (bucket79_at_daum.net)
Date: 06/09/04
- Next message: Michael Culley: "Re: Visual Basic for Autorun?"
- Previous message: Michael Culley: "Re: Visual Basic for Autorun?"
- Next in thread: Jeff Johnson [MVP:VB]: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Jeff Johnson [MVP:VB]: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Jan Hyde: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Jezebel: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Paul Clement: "Re: beginTrans without commitTrans or rollbackTrans"
- Messages sorted by: [ date ] [ thread ]
Date: 8 Jun 2004 18:16:42 -0700
hi
what if there's beginTrans without commitTrans or rollbackTrans ?
i'll show some code
Public Function test()
Dim cnnDB As ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Dim strSQL As String
On Error GoTo test_Err
test = -1
Set cnnDB = OpenConnection("some db")
Set cmd = CreateObject("ADODB.Command")
cnnDB.BeginTrans
strSQL = "some update sql....
With cmd
Set .ActiveConnection = cnnDB
.CommandType = adCmdText
.CommandText = strSQL
.Execute lngRecordsAffected, , adExecuteNoRecords
End With
If lngRecordsAffected = 0 Then
test = 1
Exit Function
End If
strSQL = "some insert sql....
With cmd
Set .ActiveConnection = cnnDB
.CommandType = adCmdText
.CommandText = strSQL
.Execute , , adExecuteNoRecords
End With
cnnDB.CommitTrans
CloseConnection cnnDB
Set rst = Nothing
Set cmd = Nothing
test = 0
Exit Function
test_Err:
cnnDB.RollbackTrans
CloseConnection cnnDB
If Not rst Is Nothing Then
Set rst = Nothing
End If
If Not cmd Is Nothing Then
Set cmd = Nothing
End If
End Function
is this code right thing?
i mean when lngRecordsAffected is 0, function exit without commitTrans
or rollbackTrans
when i test above code, update sql doesn't update table
does it means there's some rollbackTrnas silencly?
any post will be apreciated :)
- Next message: Michael Culley: "Re: Visual Basic for Autorun?"
- Previous message: Michael Culley: "Re: Visual Basic for Autorun?"
- Next in thread: Jeff Johnson [MVP:VB]: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Jeff Johnson [MVP:VB]: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Jan Hyde: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Jezebel: "Re: beginTrans without commitTrans or rollbackTrans"
- Reply: Paul Clement: "Re: beginTrans without commitTrans or rollbackTrans"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|