A
Alan Silver
Hello,
I have a generic method in a utility class that grabs an sqldatareader
and returns it. Due to the fact that (AFAIK), you can't close the
database connection before you've read the data, this method doesn't
close it, it just returns the datareader. The calling code uses the
datareader and then just lets it drop out of scope, to be picked up by
the garbage collector.
Is this a problem? A friend of mine suggested to me that not explicitly
closing the connection will leave it open, resulting in the connection
pool being emptied. I've not seen any problems on the server, but that
doesn't prove anything. I previously assumed that the connection would
be closed when the connection object was destroyed. Is this right?
Anyone care to comment? TIA
I have a generic method in a utility class that grabs an sqldatareader
and returns it. Due to the fact that (AFAIK), you can't close the
database connection before you've read the data, this method doesn't
close it, it just returns the datareader. The calling code uses the
datareader and then just lets it drop out of scope, to be picked up by
the garbage collector.
Is this a problem? A friend of mine suggested to me that not explicitly
closing the connection will leave it open, resulting in the connection
pool being emptied. I've not seen any problems on the server, but that
doesn't prove anything. I previously assumed that the connection would
be closed when the connection object was destroyed. Is this right?
Anyone care to comment? TIA