Field versions and adapter transactions

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 16-Sep-2005 20:19:48   

Greetings, I usually write code like this


        Try
            Me.SaveFields("Save")

            '... some code here

        Catch
           'if an exception is here and the adapter is in a transaction, 
           'I get an error if I try to rollback the fields ???... why?
            If Not adapter.IsTransactionInProgress Then
                Me.RollbackFields("Save")
            End If
            If isRootTransaction Then
                adapter.Rollback()
            End If
            Throw

        Finally
            If isRootTransaction Then
                adapter.CloseConnection()
                adapter.Dispose()
            End If
        End Try

The lines in question are those handling the RollbackFields. Why does this cause an error if the adapter is in the middle of a Transaction but works OK if NOT ??


           'if an exception is here and the adapter is in a transaction, 
           'I get an error if I try to rollback the fields ???... why?
            If Not adapter.IsTransactionInProgress Then
                Me.RollbackFields("Save")
            End If

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 16-Sep-2005 21:17:30   

Hmm.

A transaction already saves the fields so it's not necessary. Though rollback should work even during a transaction...

Frans Bouma | Lead developer LLBLGen Pro