SQL connection cannot unenlist from transaction - by Mark A. Nicholson

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 477809 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 7/28/2009 12:50:18 AM
Access Restriction Public


The documentation on SqlConnection, transaction binding, "Explicit Unbind" is incorrect.

The documentation states the following: "Explicit Unbind: Causes the connection to remain attached to the transaction until the connection is closed or until EnlistTransaction is called with a null reference (Nothing in Visual Basic) value. An InvalidOperationException is thrown if Current is not the enlisted transaction or if the enlisted transaction is not active. This behavior enforces the strict scoping rules required for TransactionScope support."

This suggests that it is possible to unenlist from a transaction using SqlConnection.EnlistTransaction(null);

This is NOT possible. Once a SqlConnection is enlisted in a transaction it can never be unelisted from a transaction using SqlConnection.EnlistTransaction(null). The following are the only ways a SqlConnection can unenlist from a transaction:

1. "Transaction Binding=Implicit Unbind" is specified in the connection string and the transaction ends, either by being committed, aborted or timing out, or the SqlConnection is closed (SqlConnection.Close) or disposed (SqlConnection.Dispose).

2. "Transaction Binding=Explicit Unbind" is specified in the connection string and the SqlConnection is closed (SqlConnection.Close) or disposed (SqlConnection.Dipose).
Sign in to post a comment.
Posted by Jared Moore on 8/20/2010 at 11:38 AM

Thanks for reporting this issue. It is now fixed in .Net 4.0, so EnlistTransaction(null) with Explicit Unbind now works how the documentation says.

Jared Moore
Software Development Engineer in Test
ADO.NET Managed Providers and DataSet Team
Posted by David A Nelson on 10/6/2009 at 10:52 AM
Can someone please explain how this was fixed? Is EnlistTransaction(null) now supported as per the current documentation?
Posted by Microsoft on 9/22/2009 at 11:17 AM
I was asked to not update the documentation for this issue, because it is possible that this will be fixed in code and behave as documented.

David Schwartz
technical writer
Posted by Microsoft on 7/29/2009 at 12:04 AM
Thanks for your feedback. We are routing this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team