Saturday, February 25, 2012

"New transaction is not allowed because there are other threads running in the session." -

That is a SqlException I got at a...

at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()

Anyone an idea what THAT means? How do I cause it? How can I work around it?

I think you probably have an open connection somewhere. See if you can start the transaction after you close the connection.|||

I have about 25 open connections. Because that is - quess what - an ASP.NET application.

Once connection per page.

And every page has - one thread. No multi threading at all.

Plus it is legal for a thread to have multiple open connections.

|||

Have you enabled Multiple Active Resultsets (MARS)?

For connections with MARS enabled, manual transactions started via TSQL BEGIN TRAN must end (COMMIT or ROLLBACK) within the same scope that started the transaction

If your issue meets the the aboving conditions, you can try this work aroud:

To begin tansactions that are not required to be scoped under
MARS-enabled connections, use the client driver API constructs to begin and end transactions. If existing code relies on BEGIN TRAN operations without
corresponding COMMIT/ROLLBACK, MARS can be turned off until the application can be modified to use the client driver transaction APIs

|||Nope, no MARS. Actually that was (not is) old SQL Server 2000 code from .NET 1.1 that was traansported over. Worked flawlessly under .NET 1.1, and looks flawless to me still.

No comments:

Post a Comment