Click to See Complete Forum and Search --> : connection problem


pradeep_p43
March 16th, 2002, 10:33 AM
can i have a connection in asp in session label, so that i donot have to open time and again in page level...because i hope it definitely requires more resources to open and then close in each and every page,rather then keeping it in open state and using it as reqd...
please write back (if possible with example...)
please...

Johnny101
March 19th, 2002, 05:10 PM
while true that it does take some overhead openening and closing the connection all the time it's not nearly as bad as putting objects into the session object. the problem with putting objects into the session object is two fold.

1) it's breaks that particular session into a single thread - causing overhead on the server. so the more sessions you have, the more single thread processes you have on your server, the more memory your server will use - you can see how this is going to end.

2) if you're using sql server or another higher level database, then it should have some sort of connection pooling, so as long as you dont change the connection string (not even change of case, dont change the order of the params, nothing) the server can grab one of those connections when it's asked to create one. so, by storing the connectionSTRING in an application variable, it shouldn't change throughout the application and can therefore take advantage of connection pooling.

so, although it's a pain to always have to declare and create connections on a page, level, it's actually better that way. the ideal way would be to create you own DLL that wraps ADO and place that DLL into MTS and let MTS handle the object pooling - which will help out a little with the connection pooling in SQL Server.

one other thing - putting objects into session variables severly limits your ability to scale up the website to multiple servers. actually, this is true even when you only use basic variables (strings, int, etc), but you can put strings, ints etc into the session object on a single server-website without worrying about the threading issue i talked about above.

hth,

john

John Pirkey
MCSD
http://www.stlvbug.org

pradeep_p43
March 22nd, 2002, 04:04 AM
First of all thanks for ur mail...its really a helpful one...
now it has raised another question in my mind...may be a silly one for u...but let me ask...

suppose same operation can be done in ASP(e.g. putting the connection in one page and including when reqd)...why it is advisable to use dll along with asp...what is the benefit ...rather i think calling a dll from an asp will require some extra resources...
please clarify...