Contradictory MySqlReader errors
Posted
by Lazlo
on Stack Overflow
See other posts from Stack Overflow
or by Lazlo
Published on 2010-04-01T23:00:27Z
Indexed on
2010/04/01
23:03 UTC
Read the original article
Hit count: 266
MySqlCommand command = connection.CreateCommand();
command.CommandText = string.Format("SELECT * FROM characters WHERE account_id = '{0}'", this.ID);
MySqlDataReader reader = command.ExecuteReader();
while (filler.Reader.Read()) { ... }
I get an error at the last line saying "Invalid attempt to Read when reader is closed." Now, if I add another line before it, as in:
MySqlCommand command = connection.CreateCommand();
command.CommandText = string.Format("SELECT * FROM characters WHERE account_id = '{0}'", this.ID);
MySqlDataReader reader = command.ExecuteReader();
reader = command.ExecuteReader(); // Here.
while (filler.Reader.Read()) { ... }
I get an error at that new line saying "There is already an open DataReader associated with this Connection which must be closed first."
Alright, I don't want to get picky here, but is my reader open or closed?
© Stack Overflow or respective owner