G
Guest
I have a class method that returns a DataReader
SqlDataReader parentReader = class.GetResults("55");
if(parentReader.Read())
{
..
..
}
public SqlDataReader GetResults(string County)
{
SqlDataReader myreader= My SQL statements
..
..
..
objConnection.Dispose(); //Problem is here
return myReader
}
The prob is if the parant code attempts to read from myReader, it says it
cant b/c the datareader is closed. Yet at this point the fact that the
connection created in the child class was disposed shouldnt affect a
datareader thats already loaded. The connection was local to the child class,
why should the parent datareader care? Whats the problem? If I remove the
dispose method, everything works, but I run the risk of running out of
connections in the SQL pool b/c the code is called many times.
SqlDataReader parentReader = class.GetResults("55");
if(parentReader.Read())
{
..
..
}
public SqlDataReader GetResults(string County)
{
SqlDataReader myreader= My SQL statements
..
..
..
objConnection.Dispose(); //Problem is here
return myReader
}
The prob is if the parant code attempts to read from myReader, it says it
cant b/c the datareader is closed. Yet at this point the fact that the
connection created in the child class was disposed shouldnt affect a
datareader thats already loaded. The connection was local to the child class,
why should the parent datareader care? Whats the problem? If I remove the
dispose method, everything works, but I run the risk of running out of
connections in the SQL pool b/c the code is called many times.