Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why session end but connection still there 2

Status
Not open for further replies.

hu68

Technical User
Feb 19, 2002
30
0
0
CA
Hi,all
There're a few asp page retriving data from database(Access),since all pages related with one database,I put database connection in session.As far as I know when user disconnect with the website,the everything in session will be destoried autometically.
but the strange thing is when I close the browser,the connection still there for about 15 minutes(bacause I check the database file ,the *.ldb file is there,it disappeard after 15 minutes,and I'm sure noone else use database during that time)
could some know the reason for it? any solution?
Thanks for any help !
 
Hi,all
In my case all the pages related to one database. It's still in testing phrase.before publishing it to web site I want suggestion from experienced people which method is better in my case.(set up connection in session or in every page?)Right now I put the connection in session,but it can't be destoried when I closed the browser.this is the reason I want to discuss the advantage and disadvantage about both method.
looking forward to getting more suggestion!
Thanks
 
MS Quote from the article I linked to.

Tip 5: Do Not Cache Database Connections in the Application or Session Objects
Caching ADO Connections is usually a bad strategy. If one Connection object is stored in the Application object and used on all pages, then all pages will contend for use of this connection. If the Connection object is stored in the ASP Session object, then a database connection will be created for every user. This defeats the benefits of connection pooling and puts unnecessarily high stress on both the Web server and the database.

Instead of caching database connections, create and destroy ADO objects on every ASP page that uses ADO. This is efficient because IIS has database connection pooling built in. More accurately, IIS automatically enables OLEDB and ODBC connection pooling. This ensures that creating and destroying connections on each page will be efficient.
penny1.gif
penny1.gif
 
Hi,paul
Just wnat to confirm
Does IIs autometically running connection pool ? we don't need to set up anything for it?

Thanks for your tips!
 
The connection pooling statement is nice, except when you consider that Access doesn't support connection pooling. Once again, you have to consider your environment. The excerpt above applies to Microsoft's favored set of technologies - that is a web farm for network load balancing, and a SQL Server database (or at least a datbase that supports connection pooling, as Access does not). Remove the connection pooling and network load balancing and you are back to managing resources in your code, and in this case that means it is more efficient to have the connection object at the Session level. Once again, I am not trying to attack what you are saying here, because in general I would agree with you - I just feel that it's bad form to introduce something as a hard and fast 'rule' (for example saying, "...to store them with session scope, which is just plain bad") without considering all the applicable variables involved.
 
hu68,

Connection pooling is not enabled by default in NT 4.0/IIS 4.0, though it is in Win2K/IIS 5.0. Set the following registry entry to turn it on if you need to (though, as I say above, this does you no good if your database is Access):

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\ASP\Parameters StartConnectionPool = 1
 
About Connection Pooling, how do I know IIS handle it correctly? My ASP application have database connection (to DB2) on each page, and I close and set them to nothing after I use them but there is a big memory leak discovered by my server admin, so I suspect that IIS is not doing what it claims... any idea? [sadeyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top