Hello,
I am using a reader in order to read query results:
SqlDataReader rdr = null;
SqlDataReader rdr_rows=null;
this.conn.Open();
SqlCommand cmd = new SqlCommand("select name from sysobjects where name
like '%prog%'", this.conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//some code here
}
if (rdr != null)
{
rdr.Close();
}
foreach (Dbdb data in db_coll)
{
SqlCommand cmd_rows = new SqlCommand("SELECT rows FROM sysindexes WHERE
id = OBJECT_ID('"+db_data.Name+"') AND indid < 2", this.conn);
rdr_rows = cmd_rows.ExecuteReader();
rdr_rows.Read();
System.Console.WriteLine(rdr_rows[0]);
}
I get this error:
There is already an open DataReader associated with this connection
which must be closed first.
Why? I am closing it,how to solve this?
Thanks a lot!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!