Microsoft KB Archive/309335

= An unexpected exception may occur when a transaction is committed or rolled back after a data source error has occurred =

Article ID: 309335

Article Last Modified on 3/10/2006

-

APPLIES TO


 * Microsoft .NET Framework 1.1 Service Pack 1
 * Microsoft .NET Framework 1.1
 * Microsoft ADO.NET 2.0

-



This article was previously published under Q309335



SYMPTOMS
In Microsoft ADO.NET, an exception may occur when a transaction is committed or rolled back. When you call the Commit method of a transaction, you may encounter the following exception:

The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.

Likewise, when you call the Rollback method of a transaction, you may encounter the following exception:

The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.



CAUSE
This behavior can occur if the data source has encountered a severe error, causing it to roll back the transaction immediately, rather than return control to the caller. As a result, no transaction exists when the Commit or Rollback method is called, and therefore the exception is thrown.



RESOLUTION
This behavior is by design.

However, as with any method call that may result in an exception being thrown, it is recommended that you make the method call within a try ... catch block, as shown in the following sample code:

Visual Basic: Try myTransaction.Rollback Catch e As Exception 'Handle Exception End Try C#: try {   myTransaction.Rollback; } catch (Exception e) { //Handle Exception }

Additional query words: kbreadme transaction exception

Keywords: kberrmsg kbnofix kbprb kbreadme KB309335

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.