C# mysqlreader on same connection error
- by dominiquel
Hi,
I must find a way to do this in C#, if possible...
I must loop on my folder list (mysql table), and for each folder I instanciate I must do another query, but when I do this it says : "There is already an open DataReader associated with this Connection" and I am inside a mysqlreader loop already.
Note that I have oversimplified the code just to show you, the fact is that I must do queries inside a mysqlreader loop, and it looks to be impossible as they are on the same connection?
MySqlConnection cnx = new MySqlConnection(connexionString);
cnx.Open();
MySqlCommand command= new MySqlCommand("SELECT * FROM folder WHERE folder_id = " + id, cnx);
MySqlDataReader reader= commande.ExecuteReader();
while (reader.Read())
{
this.folderList[this.folderList.Length] =
new CFolder(reader.GetInt32"folder_id"), cnx);
}
reader.Close();
cnx.Close();