User Controls and ADO connections

G

Guest

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
 
M

Marina

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.
 
S

S. Justin Gengo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top