IDbTransaction Rollback Timeout

Posted by Ben on Stack Overflow See other posts from Stack Overflow or by Ben
Published on 2009-08-12T08:36:17Z Indexed on 2010/03/28 19:03 UTC
Read the original article Hit count: 351

Filed under:
|
|
|
|

I am dealing with an interesting situation where I perform many database updates in a single transaction. If these updates fail for any reason, the transaction is rolled-back.

IDbTransaction transaction
try {
    transaction = connection.BeginTransaction();

    // do lots of updates (where at least one fails)

    transaction.Commit();
} catch {
    transaction.Rollback(); // results in a timeout exception
} finally {
    connection.Dispose();
}

I believe the above code is generally considered the standard template for performing database updates within a transaction.

The issue I am facing is that whilst transaction.Rollback() is being issued to SQL Server, it is also timing out on the client.

Is there anyway of distinguishing between a timeout to issue the rollback command and a timeout on that command executing to completion?

Thanks in advance, Ben

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about ADO.NET