In a web application, the page is recreated each time (if you keep the
connection string in a page member it will be reinitialized the next time as
the page just lives the time of the HTTP request).
Also you generally open/create the connection each time you need it to avoid
:
- having a unique connection for all users (it would block users majking
this single connection a bottleneck)
- haing a connection for each user (it would use a vast amount of resources)
ASP.NET uses a connection pool. When you create a connection, it is taken
from the pool. When you close it, it is returned to the pool. This way you
only need as much connections, as you have current requests executing (ie.
you could server 100 users with 10 connections).
Patrice
--
"Saulot" <sa****@libertysurf.fr> a écrit dans le message de
news:41**********************@news.free.fr...
Hi,
Facing a big problem.
In my Default.aspx page, I open a connection with ma Sql Server DataBase
through my objects framework (A "SetDefaultConnectionString" property
which open my connection... work fine with winforms)
My Default.aspx page is a login one.
When I log in, no problem, I got my
Response.Redirect("DefaultEmployee.aspx") which works well. Then, I click
on another Redirect which leads me to the employee's personnal informations
and THERE, Problem.
BUT, using spy window, I can see that just after the Redirect thing, my
connectionstring is set to nothing !!!
So here is the point.
Is there a place to open my connection that it'll be available for the
whole pages of my site and so on, a place to close it when my user lives the
site. I tried Application_start and didn't work.
Help please.