G
Guest
I keep getting this irritating exception on and on. Please Help.
There is already an open DataReader associated with this Connection which
must be closed first.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.InvalidOperationException: There is already an
open DataReader associated with this Connection which must be closed first.
Source Error:
Line 84: OdbcCommand myCommand = new
OdbcCommand(mySelectQuery,myConnection);
Line 85: myConnection.Open();
Line 86: OdbcDataReader myReader = myCommand.ExecuteReader();
Line 87: myReader.Close();
Line 88:
Here is that part of the source Code..
private void CheckUser()
{
string connectionString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;" +
"DATABASE=markingsystem;" +
"UID=akramm;" +
"PASSWORD=rootuser;";
string mySelectQuery = "SELECT * FROM account_details";
OdbcConnection myConnection = new OdbcConnection(connectionString);
OdbcCommand myCommand = new OdbcCommand(mySelectQuery,myConnection);
myConnection.Open();
OdbcDataReader myReader = myCommand.ExecuteReader();
myReader.Close();
}
Note please that I only have 1 datareader, so the exception doesnt make
sense to me..
Your kind comments will be very much appreciated...
Thanks,
Irfan
There is already an open DataReader associated with this Connection which
must be closed first.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.InvalidOperationException: There is already an
open DataReader associated with this Connection which must be closed first.
Source Error:
Line 84: OdbcCommand myCommand = new
OdbcCommand(mySelectQuery,myConnection);
Line 85: myConnection.Open();
Line 86: OdbcDataReader myReader = myCommand.ExecuteReader();
Line 87: myReader.Close();
Line 88:
Here is that part of the source Code..
private void CheckUser()
{
string connectionString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;" +
"DATABASE=markingsystem;" +
"UID=akramm;" +
"PASSWORD=rootuser;";
string mySelectQuery = "SELECT * FROM account_details";
OdbcConnection myConnection = new OdbcConnection(connectionString);
OdbcCommand myCommand = new OdbcCommand(mySelectQuery,myConnection);
myConnection.Open();
OdbcDataReader myReader = myCommand.ExecuteReader();
myReader.Close();
}
Note please that I only have 1 datareader, so the exception doesnt make
sense to me..
Your kind comments will be very much appreciated...
Thanks,
Irfan