IsTransactionInProgress returns True with no transaction active

Posts   
 
    
eugene
User
Posts: 85
Joined: 05-Oct-2004
# Posted on: 19-Jun-2007 16:51:49   

Hi there,

I have the following routine at the end of my operations:

        
If _adapter.IsTransactionInProgress
    _adapter.Rollback()
End If

A few times a day I am getting the following error: SQL transaction was ended and cannon longer bu used (rough translation!).

I am assuming that the SQL server has ended the transaction while ado hasn't taken notice of this. Is it possible to find out about this? What are the common causes for such (mis) behaviour?

Thank you for your assistance!

Aurelien avatar
Aurelien
Support Team
Posts: 162
Joined: 28-Jun-2006
# Posted on: 19-Jun-2007 17:44:57   

these situations can happen and ADO.NET doesn't know about this/isn't notified. This happens when an error inside sqlserver occurs which has severity > 20.

Example is FK violation when deleting a row. This terminates the transaction inside sqlserver. In some occasions it could be that sqlserver terminates the transaction, then throws an exception, which then ends up in the code which then ends up in the catch clause of the routine which perhaps calls Rollback.

At that point you get another exception because the transaction is already gone because sqlserver has already rolled it back.