none
MARS (Multiple Active Result Sets) gives no effect RRS feed

  • Question

  • I am developing WinForm wih VS2005 and SQL Server 2005 Express

     

    I created few queries within few threads. And i got different random errors about connection like:

    - Internal .Net Framework Data Provider error 12.

    - Invalid operation. The connection is closed.

    - There is already an open DataReader associated with this Command which must be closed first.

    - ExecuteReader requires an open and available Connection. The connection's current state is open.

    - ExecuteReader requires an open and available Connection. The connection's current state is connecting.

     

    I searched about the issue and I got "MultipleActiveResultSets=True" should be added to connection string.

     

    But still I got the same error. I've double checked the connection string.

    Are there some configuration i missed here?

     

    ps:

    I have another option not to use MARS for my connection string. But creating multiple SQLConnection used for each thread, like:

    Dim conn_1 as new SQLConnection(connstring)  --------> for query 1 in thread 1

    Dim conn_2 as new SQLConnection(connstring)  --------> for query 2 in thread 2

    Dim conn_2 as new SQLConnection(connstring)  --------> for query 3 in thread 3

    But actually this supposed to be done by enabling the MARS only, isn't it?

     

    Thank You in advance



    • Edited by Vin Owen Saturday, November 19, 2011 3:31 AM
    Saturday, November 19, 2011 2:07 AM

Answers

  • Hi Vin,

    After researching, I find a case which is similar with yours, and the issue has been solved, please refer to it.

    To define multiple connections in different thread is a common option. More information about MARS, please refer here.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by Vin Owen Monday, November 21, 2011 10:52 AM
    Monday, November 21, 2011 8:48 AM
    Moderator

All replies