System.Data.SqlClient.SqlException : The operation failed because the session is not single threaded

Hi,

When does "System.Data.SqlClient.SqlException: The operation failed because the session is not single threaded" exception get thrown ?

We have a web application and the above exception get thrown in our DataAccessLayer when we try to open the connection to the database. The DataAccessLayer is single threaded we do not spawn any thread explicitly.

A web request is processed using the same thread that is allocated by IIS internally.

We have .Net 3.5 framework and SQL Server 2008 R2.

This issue does not occur always, but randomly fails at SqlConnectionObj.Open() statement. We do not have a case where we read data from DB and while reading through the DataReader we update the Db records. Out control flow is as follows.

1. Open the DB connection - SqlConnectionObj.Open()

2. Create a CommandObject - CommandObj = new SqlCommand();

3. Create a Transaction - TransactionObj = ConnectionObj.BeginTransaction();

4. Set the CommandObject .Transaction = TransactionObj ;

5. Reader = CommandObject .ExecuteReader();. Iterate Reader and close it.

6. CommandObject .ExecuteNonQuery()

7.  Steps 5 and 6 can be executed multiple times and in different sequence based on business logic.

8. Commit/Rollback operation.

9. Finally Close DB connection.

I have already seen the following link

http://blogs.msdn.com/b/cbiyikoglu/archive/2006/11/21/mars-transactions-and-sql-error-3997-3988-or-3983.aspx

We do not use MARS. Our connection string does not have "MultipleActiveResultSets" property. Thus my problem does not seem to get answered from the above post.

I have posted the question on .Net framework forum too.

http://social.msdn.microsoft.com/Forums/en-US/0cd5e454-24ce-46fb-8740-4857418c6937/systemdatasqlclientsqlexception-the-operation-failed-because-the-session-is-not-single-threaded?forum=netfxbcl

Regards,

Anand Mahadik

October 28th, 2013 3:21am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics