Click to See Complete Forum and Search --> : Issues rising in storing DB connection in session variable.


hndlogic
02-17-2007, 12:27 AM
Hi

I need to ask, which one is better ?

1) Opening db connection on the top of page and closing it at the end.

2) Opening db connection and saving it in Session variable OR Application variable. And closing it only in global.asa Session_End event.

Which one is better. Also I need to know the advantages and disadvantages of these two.


Thanks.

russell
02-17-2007, 12:12 PM
1 is far better. you want to close connections as soon as possible, freeing the resource for other threads. there is no advantage to method 2.

buntine
02-18-2007, 06:48 AM
For the sake of it, I agree with Russell.

There is no inherant rubbish collection in ASP, so explicitely opening and closing objects is very important.

Cheers,
Andrew.

russell
02-18-2007, 08:41 AM
Cheers,
Andrew.

He's Back! :eek:

buntine
02-18-2007, 09:11 AM
:cool: It's about time, too!