PDA

View Full Version : Global Database Connection


codefox
12-03-2002, 05:49 AM
Is it possible to have just one global connection which could be used in all asp pages. Right now I have an file with the connection.open statement which I include in the asp pages where I need to connect to the database. Is it possible to open a connection in global.asa and use that object in all asp pages?

Thanks.

glenngv
12-03-2002, 06:16 AM
yes it's possible but not recommended.
why? because not all of your pages would need the db connection, so all the time each user has the handle on the connection but NOT all the time he needs it.
You don't have to worry about opening and closing the connection in every page because you can enable Connection Pooling to handle re-use of open connection handles

here are some links about connection pooling:

http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=connection+pooling+with+asp

codefox
12-03-2002, 06:41 AM
So if I enable connection pooling, would my pages load a bit faster (i assume there would be a decrease in time taken for connecting to the database due to connection pooling)? Also, does enabling connection pooling affect the behavior of my program execution? I mean would that affect the behavior of any triggers or stored procedures?

Thanks.

glenngv
12-03-2002, 07:37 AM
definitely the pages would load a bit faster when connection pooling is on. The difference may be obvious if there are many concurrent users and your database is big.

regarding stored procs and connection pooling, here's one of the links that was returned by the google search that I posted above.

http://www.15seconds.com/faq/ODBC/481.htm