The SqlTransaction has completed; it is no longer usable RRS feed

  • Question

  • Hello

    When using serializable transactions in concurrent tasks, i get the following exception: InvalidOperationException: The SqlTransaction has completed; it is no longer usable. 

    generally this exception is raised after a deadLock.  when i check my data on the database, even if this exception occurs, the data is comitted.

    I added log information to check all the operations related to my transaction and i am sure that only one BeginTran and one Commit is used. 

    For more information please see the following screenshots


    .NET 4.0

    Microsoft SQL Server Developer Edition (64-bit) 10.50.4000.0

    developpeur C#

    Wednesday, January 22, 2014 5:06 PM


All replies

  • Hi,

    It looks that you are sharing the transaction between different threads and one of them ends and do the commit and disposes the connection and other gets this error, but I can't be sure by the code you show here.

    If you need more help please post the code that generates the concurrent tasks.


    Wednesday, January 22, 2014 8:00 PM
  • Hi

    Thank you for your answer.

    I am not sharing the transaction between my taks. Each Task has its own connection and transaction. 

    for a unknown reason, my SQLTransaction becomes Zombie and its connection is set to nothing even if the connection exists (I showed this in the first screenshot)

    I think that this issue belongs to a DeadLock which is not returned corrctly by ADO.NET. When i do a Commit, it detects that it cannot be done because of a deadLock and it raises an InvalidOperationException instead of a DeadLockException

    I added here three screenShots to show you that Transaction are not shared between tasks.

    developpeur C#

    • Edited by You_cef Thursday, January 23, 2014 9:14 AM
    Thursday, January 23, 2014 8:34 AM

  • developpeur C#

    Thursday, January 23, 2014 9:15 AM
  • Hello You_cef,

    Have a try to use below code block to catch the details error message:

    catch (Exception ex2)
            Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
            Console.WriteLine("  Message: {0}", ex2.Message);

    And please check if you in such an scenario:



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Monday, February 3, 2014 8:50 AM
    Tuesday, January 28, 2014 7:19 AM