programming.torensma.net: Code Snippets

MultipleActiveResultSets (MARS), SQL server 2000 and LINQ

Using the MultipleActiveResultSets setting in a connection string allows one to have multiple datareaders open on the same connection, at the same time. This setting was introduced with SQL server 2005. Setting it with SQL server 2000 does not have any effect, or so I thought.

It turns out that when using ordinary queries, datareaders and datasets,  MultipleActiveResultSets doesn’t have any effect on SQL server 2000. But when using LINQ, it does! Somehow, the LINQ engine reads the setting and handles different depending on it. In my situation, this resulted in There is already an open DataReader associated with this Command which must be closed first. errors when connected to SQL server 2000. Removing the setting from the connection string also stopped the error from occuring.

You can follow any responses to this entry through the RSS 2.0 feed.