Already Open DataReader

Tags: .NET, SQL

Today I was getting following error when running one of our applications:
”There is already an open DataReader associated with this Command which must be closed first.”

This happens when you have multiple DataReaders open on the same connection. Note that this can also be because you’re iterating through LINQ query results, which internally also use DataReaders.

To solve this (on SQL Server 2005 + .NET 2.0 or later) add “MultipleActiveResults=True” to your connection string.

Comments

comments powered by Disqus