.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 30th, 2009, 10:12 AM
xrum xrum is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 27 xrum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 42 m 42 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old October 30th, 2009, 11:43 AM
richyrich's Avatar
richyrich richyrich is offline
Contributing User
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Somewhere only we know...
Posts: 4,220 richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 1 Week 3 Days 14 h 27 m 36 sec
Reputation Power: 1441
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...

Reply With Quote
  #3  
Old October 30th, 2009, 11:46 AM
xrum xrum is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 27 xrum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 42 m 42 sec
Reputation Power: 0
yes it does. thank you!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Closing Connection in CLASS


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek