473,387 Members | 1,760 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.

User Controls and ADO connections

I have 3 User Control .ascx files that are included in a base .aspx file.

In each ascx file, as well as the base aspx file, I make ADO.Net calls that
require a datatbase connection.

It appears that I have to open and close the connection in each file (i.e. I
can not reuse the open connection between all 4 pages)? This means that I
must open and close the connection 4 times when servering one page (base aspx
and 3 ascx files).

Is there any way that I can accomplish this without so opening and closing
the connection so many times?

Wouldn't this become a scalability problem if I continually have to open and
close connections multiple times on each page?

I have thought about using a session variable for the connection, but I have
read the MS does not recommend using a session variable for the connection?

TIA
Nov 19 '05 #1
3 1020
I don't think it would be a problem. In fact, the longer you keep a
connection open, the more a scalability problem it may be, since presumably
most of that time the page is actually doing other things. So if you keep
connections open for long periods of times, when you get many users hitting
your site, there may not be enough to go around.

I would say you are doing it the right way. This is the most manageable and
maintainable, since each control can clean up after itself.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
I have 3 User Control .ascx files that are included in a base .aspx file.

In each ascx file, as well as the base aspx file, I make ADO.Net calls
that
require a datatbase connection.

It appears that I have to open and close the connection in each file (i.e.
I
can not reuse the open connection between all 4 pages)? This means that I
must open and close the connection 4 times when servering one page (base
aspx
and 3 ascx files).

Is there any way that I can accomplish this without so opening and closing
the connection so many times?

Wouldn't this become a scalability problem if I continually have to open
and
close connections multiple times on each page?

I have thought about using a session variable for the connection, but I
have
read the MS does not recommend using a session variable for the
connection?

TIA

Nov 19 '05 #2
Paul,

Marina is absolutely correct, on top of that if you're connecting to a SQL
database .NET's built in connection pooling reuses connections in the most
efficient manner automatically.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Marina" <so*****@nospam.com> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
I don't think it would be a problem. In fact, the longer you keep a
connection open, the more a scalability problem it may be, since presumably
most of that time the page is actually doing other things. So if you keep
connections open for long periods of times, when you get many users hitting
your site, there may not be enough to go around.

I would say you are doing it the right way. This is the most manageable
and maintainable, since each control can clean up after itself.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
I have 3 User Control .ascx files that are included in a base .aspx file.

In each ascx file, as well as the base aspx file, I make ADO.Net calls
that
require a datatbase connection.

It appears that I have to open and close the connection in each file
(i.e. I
can not reuse the open connection between all 4 pages)? This means that I
must open and close the connection 4 times when servering one page (base
aspx
and 3 ascx files).

Is there any way that I can accomplish this without so opening and
closing
the connection so many times?

Wouldn't this become a scalability problem if I continually have to open
and
close connections multiple times on each page?

I have thought about using a session variable for the connection, but I
have
read the MS does not recommend using a session variable for the
connection?

TIA


Nov 19 '05 #3
it is adviced to keep the connection for a minimal amount of time.. so your
current approch is efficient

Following may help, "Best Practices for Using ADO.NET"

http://msdn.microsoft.com/library/en...st_topic5&_r=1

"Paul" wrote:
I have 3 User Control .ascx files that are included in a base .aspx file.

In each ascx file, as well as the base aspx file, I make ADO.Net calls that
require a datatbase connection.

It appears that I have to open and close the connection in each file (i.e. I
can not reuse the open connection between all 4 pages)? This means that I
must open and close the connection 4 times when servering one page (base aspx
and 3 ascx files).

Is there any way that I can accomplish this without so opening and closing
the connection so many times?

Wouldn't this become a scalability problem if I continually have to open and
close connections multiple times on each page?

I have thought about using a session variable for the connection, but I have
read the MS does not recommend using a session variable for the connection?

TIA

Nov 19 '05 #4

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

Similar topics

8
by: Maddman | last post by:
Newbie here. I've got my database set up in SQL 2000, and have started an Access adp for a front end. I have 10 licenses, and at the moment the only accesses are the server through Remote...
5
by: Jeff MacDonald | last post by:
Hi, WHen i run pg_dumpall as the super user it asks for a password for every database. I don't know my users passwords. Is there a way to make the super user able to backup without passwords ?...
2
by: Blake Versiga | last post by:
I am pulling my hair out..... I am trying to put a bound data grid on a webform... I have 4 data connections in my server explorer, all of which connect successfully. But when I run the web...
5
by: jqpdev | last post by:
Hello all... I'm coming from a Borland Delphi background. Delphi has a specific component called a Data Module. In the designer the Data Module behaves like a windows form. A developer can...
3
by: A. Elamiri | last post by:
Hello, I have web controls which pull information off a database. These controls pull things like Events, and so on. Each one of these controls use different business objects which create the...
8
by: Mats Lycken | last post by:
Hi, I'm working on a webproject where I have several different user controls loaded on a WebForm. A problem arises when I in one webcontrol makes a change that should be picked up by another user...
11
by: Ted | last post by:
I have figured out how to use MS SQL Server Management Studio for SQL Server 2005, including how to create users. At my client's offices, on my own LAN (a one man office with two computers in a...
9
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
5
by: Paul Hemans | last post by:
Hi, I am using VS2005. I have a form with a tabControl on it. Suddenly I can no longer see any of my controls, on any of the pages, or even the tabControl itself. They still exist because the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.