Home

SQL Auzure issue

Folks,

I am getting an error on my SQL azure connection that aI do not get on my local SQLExpress connection:

There is already an open DataReader associated with this Command which must be closed first
void Main()
{
	var cs= from c in TableNumber1
			orderby c.field1
			select c;
	DateTime d = DateTime.Parse("1/16/2011");
	while (d < DateTime.Now)
	{
		var t = from f in cs where f.field1 >= d && f.field1 < d.AddDays(1) select f;
		foreach (var a in t)
		{
			if (a.RecipientId != null)
				CallStoredProcedureNumber1(a.field1);
		}
		CallStoredProcedureNumber2();
		d = d.AddDays(1);
	}
}
I suspect that I can force the first query to execute fully with .ToList(), but, if I wish to avoid that solution, is there a way around this single open data reader problem?

Sign In or Register to comment.