20 % from what ? Even 100 % wouldn't mean anything. If it's small enough
this is anyway non visible to the end user...
This is not really "more efficient". It just much simpler and it guarantees
that connection are released as soon as possible...
If you keep the connection opn :
- any failure to close the connection could cause problem
- it could be closed later than needed making this connection not available
even though not used
- if you have some processing between those openings, this particular
connection is not available even though not used at this time...
As most often this is a matter of trade off... The thing to check is if
your DB supports connection pooling...
--
Patrice
"jc" <> a écrit dans le message de news:
b5a3f06b-7f58-429a-95ff-e3b3dca3cff5...oglegroups.com...
> Hi there:
>
> Reading from internet i found that the best way to use a database is
> to connect and disconnect on every single database request, so if you
> are loading a listbox manually from a database and on the same page,
> loading a grid from the database, then the best way is to connect to
> database, load the listbox, disconnect, connect again, load the grid
> and disconnect.
>
> what is the cause because to reconnect many times is more
> efficient?.
>
> I tried running some test on about it,connecting once on page request
> is almost 20% more fast that connecting many times.
>
> Also, i checked the number of session open on oracle and in both
> method did keep the same number of session. In any case, aspnet will
> keep many connections opens (persistent?). May be this method of open
> and close for request is efficient with sqlserver but other database.
>