I don't understand what you mean by allowing multiple users to access one connection. A connection is just that - a connection, not a result set. If you were to have EVERYONE using the same connection, your performance would be very, very poor. This again is the case with your recordset. Why would you even want all of your users to share the same recordset object? Your performance would suffer greatly.
As to your question about the difference between server load on a session variable vs. a normal variable. A session variable does not go out of scope until the session expires - if I remember right the default session expiration time in IIS is 20 minutes AFTER the last request from a user. On the other hand, a "normal" variable goes out of scope as soon as the processing for the page is complete - often less than a second. So, for arguments sake, lets say that your recordset object uses 50k of memory. Stored in a session variable, that is 50k used FOR EACH VISITOR, for AT LEAST 20 minutes. Stored in a "normal" variable, that is 50k for a fraction of a second.
I cannot think of a "normal" situation where storing a recordset or connection object in a session or application variable is a good idea. In fact, many web hosts do not allow this activity as it places too heavy of a load on the server. Many sites have dynamic content generated from a database, and an effective approach is to create your connection, create a recordset, loop throug the results, then - optimally - close the connection. Even if the connection isn't explicitly closed via script, it will automatically be closed when the page is complted processing - however this is considered poor practice.
Quote:
|
Originally Posted by D.Viddy
I've been reading an ASP 3.0 book and I was wondering if anyone had any input on the best place to store a database connection (to minimize server load). Would an application variable be the best place to store this connection? I want multiple users to be able to access one connection. Also I don't see how I could also store the recordset object to allow mulitple users to access one object. I guess I could put it in a session variable, but I think that would be very bad for the server. But putting the recordset into a session variable wouldn't be any different than putting it in a normal variable right? My web application relies heavily on the database to fill out all the pages. So if I was to store one recordset object in a session variable that would actually be better then making the server open and close a recordset multiple times for each page they visit? I'm I correct in this thinking?
|
|