none
TransactionScope rollback problem RRS feed

  • Question

  •  

    I am using TransactionScope in a loop and have found that if I don't commit 2 records, the first one rolls back but then I get an error on the second one. Interestingly, putting a sleep(3000) before the 2nd rollback fixes the problem. However this is clearly not a satisfactory solution so I was wonding if anyone knows whats going on!

     

    Here is an example of the code I'm using...

     

    For Each person In PersonList

       Using EntitySubScope As New TransactionScope

       ***********************************************************

       various select/insert/updates are carried out here...

       ***********************************************************

          If blnError = False Then

             EntitySubScope.Complete()

          End If

       End Using

    Next

     

    Where blnError=False for more than 1 record, there is a long pause and then the following:

    'Invalid operation. The connection is closed.'

     

     

    Any ideas?

    Monday, March 31, 2008 3:39 PM