473,387 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Opening and closing connections

If you have ASP.Net pages that contain multiple user controls and reference
multiple classes, is it better to:
1. Open a single connection and pass it around to all objects that need to
access data, or
2. Open a connection within each individual control, page, or class for
internal usage, or
3. Open a connection each time data needs to be accessed?

If 1 or 2, how do you make sure the connection gets closed? Thanks!
Feb 7 '06 #1
1 1084
Your last question is one of the problems I was going to point out before I
finished reading the thread. I usually open and close the connection
immediately around where I need the data. That way I know the resources are
released.

"JAdrianB" <JA******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
If you have ASP.Net pages that contain multiple user controls and
reference
multiple classes, is it better to:
1. Open a single connection and pass it around to all objects that need
to
access data, or
2. Open a connection within each individual control, page, or class for
internal usage, or
3. Open a connection each time data needs to be accessed?

If 1 or 2, how do you make sure the connection gets closed? Thanks!

Feb 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dustin lee | last post by:
Over the years I've gotten out of the habit of explicitly closing file objects (whether for reading or writing) since the right thing always seems to happen auto-magically (e.g. files get written...
3
by: Anthony | last post by:
Hey all, Here's a question for you, my hosts have told me that that one my pages, php, was causing their server to reboot because there were too many open connections and that they should be...
3
by: Greg | last post by:
On my report I want to have an opening balance signifying all transactions up to the month selected and detailed transactions for the month selected and then a closing blance. I'm perpelexed...
1
by: C Sharp beginner | last post by:
I'm sorry about this verbose posting. This is a follow-up to my yesterday's posting. Thanks William for your reply. I understand it is a good practice to open connections as late as possible and...
5
by: Daves | last post by:
is it a good or bad practise to use the session_start & session_end for opening & closing the database connection? I'd thought that on powerful servers today the time the connection is kept locked...
4
by: arbpen | last post by:
I am concerned about performance. Usually, in a situation where I am not using a global.asa (shared host, etc), I explicitly close the connection at the bottom of the page in a footer, eg:...
7
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I...
5
by: Ravimama | last post by:
Hi People, I have been coding in vb.net and c# for last six months, I am new to coding and we are using 3 tier architecture. In the DAL in each and every method I open the connection and close...
2
by: Stephen2 | last post by:
I've written a small dos batch script that runs a simple query through osql and then calls an exe which sends an email if the returned value The query checks if a value in a column has not been...
4
by: kessa | last post by:
Hi Guys, I've recently had a problem with my site displaying a "system resources exceeded" error message ... and whilst searching this site for a solution (which I think I've now found) I came...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.