msg:There is already an open DataReader associated with this
Command which must be closed first
<add name="ConnectionString"
connectionString="Data
Source=abc\ABCD;Initial Catalog=XYZZ;Integrated Security=True;
MultipleActiveResultSets=true"
providerName="System.Data.SqlClient" />
This happens when you have
multiple DataReaders open sametime on the same connection. If you call
SqlCommand.ExecuteReader but don't close the SqlDataReader returned before
calling it again.(Ex: Within a while loop you call another method which opens a
data reader).
Solution is to make MultipleActiveResultSets to
true in App.Cofig connection string. This is applicable to SQL 2005 and above.
No comments:
Post a Comment