hi,
I need to use a few SQLDataReader objects in my application. I need to do
something like that:
System.Data.SqlClient.SqlConnection conn = new SqlConnection(string);
conn.Open();
System.Data.SqlClient.SqlCommand com = new SQLCommand(string, conn);
SqlDataReader data1 = com.ExecuteReader();
while(data1.Read())
{
//read a new SQLDataReader
}
conn.Close();
the problem is in the loop. I need to read a new datareader for each data in
data1
the problem is that I must create a new connection to database and associate
that with a new sqldatareader. It is stupid - for any new sqldatareader a new
connection to db must be established.
If I try to do:
com.CommandText="new statement";
SQLDataReader data2 = com.ExecuteReader();
I am thrown the error (something like this):
There is already an open dataset associated with this connection. Close this
first