I agree, that for the ObjectDataSource the closing should be handled by its Select method. My ObjectDataSource Select method returns a SqlDataReader. My concern is ... will the SqlDataReader be rendered useless when closed after returning it to the UI. e.g. see the following sample code. I have not tried it and don't want to do it at this stage of development.
SqlDataReader MySelectMethod(){
SqlDataReader dr = null;
try{
dr = DBObject.GetDataReader();
return dr;
}
finally{
dr.Close();
}
}
Thanks for all the inputs received so far !
...........
My understanding is that with
SqlDataSource, connection management
is performed for you, and you have
nothing to fear.
ObjectDataSource doesn't talk to the
database directly in the first place,
so it will be safe -- as long as the
underlying object performs its
connection and reader management
correctly.
As others have mentioned, Close() and
using are your friends for the classes
you use with ObjectDataSource
.