Detect if a transaction is already rolled back

Posts   
 
    
Claus
User
Posts: 1
Joined: 13-Sep-2005
# Posted on: 13-Sep-2005 10:00:58   

Hi

Does anybody know a solution to following scenario ? We are using LLBLGen Pro v1.0.2004.2 and SQL Server 2000.

We start a new transaction and save an entity using Adapter.SaveEntity(...) This will cause a trigger to fire (check if a combination of code values are valid). If a given combination are not valid raiseerror is called followed by rollback transaction.

As our code (SaveEntity) is within a try-catch block we detect the raise error which lead us to call databaseAdapter.Rollback(). But as the transaction already is rolled back (by the trigger) this will cause a new exception.

So my question is: How can I detect that the transaction is already rolled back ? using databaseAdapter.IsTransactionInProgress return true in this case.

Thanks in advance.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 13-Sep-2005 21:18:14   

No that's not possible I'm afraid, as the ADO.NET transaction is controlled by Sqlserver, and there's no property in ado.net which tells you if a transaction is rolled back on the server. Similar thing pops up when a severe error occurs in sqlserver during a transaction and sqlserver decides to roll back the transaction already. Calling sqltransaction.rollback again will then throw an exception.

Frans Bouma | Lead developer LLBLGen Pro