MySqlDataReader multiple use - best practice
Posted: Mon 13 Jul 2009 14:49
What is the best practice for using MySqlDataReader for multiple query's ?
I have a procedure that does something like below. The problem is that the MySqlDataReader gets corrupted after 5-6 iterations.
I noticed that if I do a closeConnection then openConnection, I do not get any corruption in the MySqlDataReader.
MySqlDataReader mr;
for many transaction types:
OpenDataSet(sqlStmt)
procedure OpenDataSet(string sqlStmt)
if ( mr != null && !mr.IsClosed ) mr.Close()
// if closeConnection here then all is fine.
if ( connection not open) openConnection()
mr = ExecuteReader()
case transactionType
do your thing
mr.Close()
I have a procedure that does something like below. The problem is that the MySqlDataReader gets corrupted after 5-6 iterations.
I noticed that if I do a closeConnection then openConnection, I do not get any corruption in the MySqlDataReader.
MySqlDataReader mr;
for many transaction types:
OpenDataSet(sqlStmt)
procedure OpenDataSet(string sqlStmt)
if ( mr != null && !mr.IsClosed ) mr.Close()
// if closeConnection here then all is fine.
if ( connection not open) openConnection()
mr = ExecuteReader()
case transactionType
do your thing
mr.Close()