.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:20 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
Open SQL Connections

Hi,

I am a newbie, how can I check that all my connections get closed, as I go through the app?


also, as for efficiency, is it better to hard code things in, or take them from a db?


for example,

i have multiple states drop down list. I can either hard code the array in, and reference it all over the place, or i can make a db table.

which is more efficient?


thanks in advance!

Reply With Quote
  #2  
Old October 30th, 2009, 12:22 PM
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
If you use a Using declaration on your connection, .NET automatically closes it when it reaches the end Using call.

In VB
Code:
Dim conn as new Connection....

Using Conn


End Using

C#
Code:
connection conn = new Connection...

using (conn)
{

}

I still tend to include calls to Close() methods and have using as a fail safe to catch any I miss. Bit of overkill maybe...

In terms of efficiency, if you think about it in terms of getting the information you want in the least number of hops. So, a call to a database will always be less efficient as it's another hop to getting the data you need.

It's more a case of ascertaining what functionality you need. If it's a simple yes/no dropdown, then hard code it. If it's likely to change / update regularly then use a database.

If using a database, it may be more efficient is to pass the values into cache on Application Start and then access them from there each time you need them. Then if they get updated, make sure you call a method to update the cached version.

All depends how often the values will be needed, how much memory would they take up etc. It's a matter of measuring how much resource would be used against the increased efficiency of getting the data from memory rather than the db each time.

Hope that helps.
Comments on this post
micky agrees!
__________________
Policy Check

I'd rather have a full bottle in front of me, than a full frontal lobotomy...

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Open SQL Connections


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 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek