You don't close the datareader in the function. But you do pass
CommandBehavior.CloseConnection to the ExecuteReader.
Then, whatever code is calling the function is responsible for calling Close
on the data reader. Since you passed in CloseConnection to ExecuteReader,
closing the datareader will close the connection as well.
Or, you can rethink this, and see if your function can return a DataTable
instead, then you dont' have to deal with any of this, or worry about
remember to close the datareader when you are done.
<jj****@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi,
I have a situation where in a dll a SqlDataReader is created on a
function call but is never closed. The datareader gets passed back to
the asp.net page calling it. How should I close the SqldataReader in
the function where it is being created properly? If I close the
SqlDataReader in the function my datareader returns nothing of course.
So how do I code it properly to pass back a datareader and close it in
the function?
Thanks,
J