|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Closing Connection in CLASS
Hi,
I populate a drop down list from a database. My getValues function is in a class, that I call, which is where i Open my connection and the dataReader. I then return the dataReader value, and binding the data to the drop down. I cannot close the connection in the class function(before return), as I will not be able to bind the data to the drop down later. what are the usual procedures with this? How do I make sure all my connections are closed when I'm done with that query? Thank you |
|
#2
|
||||
|
||||
|
You would normally populate some form of Collection object in your GetValues function and return that instead of the DataReader.
That way you can close up all your db connections etc. before returning the collection and using that as your datasource. Something like a Dictionary or Hashtable. You loop through the datareader, populating your collection object, close up the db connection and return the object. Hope that helps.
__________________
Policy Check I'd rather have a full bottle in front of me, than a full frontal lobotomy...
|
|
#3
|
|||
|
|||
|
yes it does. thank you!
|
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > Closing Connection in CLASS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|