beginTrans without commitTrans or rollbackTrans

From: bucket79 (bucket79_at_daum.net)
Date: 06/09/04


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 :)



Relevant Pages

  • Re: reusing command object
    ... recordset and make updates to certain records. ... Dim cmd As New ADODB.Command ... Dim rst As ADODB.Recordset ... its better to write "Dim rst As ADODB.Recordset". ...
    (microsoft.public.access.adp.sqlserver)
  • RE: Datagridview requery
    ... dataadapter. ... However, I'm unable to do this, I just can't get the data to refresh. ... Dim cnn As New SqlClient.SqlConnection(_ ... Dim cmd As New SqlClient.SqlCommand ...
    (microsoft.public.dotnet.languages.vb)
  • Re: SqlDataReader.Read() with image data type size 65,535
    ... it happens when I change data type to 'text'. ... Dim conn As New SqlConnection ... Dim cmd As SqlCommand ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Parameter has no default value
    ... conn = New OleDbConnection ... cmd = New OleDbCommand ... Dim conn As OleDbConnection = Nothing ... Dim paramCategory As OleDbParameter = Nothing ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SqlDataReader.Read() with image data type size 65,535
    ... Private Sub Button1_Click(ByVal sender As System.Object, ... Dim conn As New SqlConnection ... Dim cmd As SqlCommand ...
    (microsoft.public.dotnet.framework.adonet)

Loading