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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Arrays??

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
Guys,

I have a page that gets called by itself several times and displays information that it reads from a database. However, at the moment it is extremely inefficient as each time the page is accessed it reads the data from the database. Is there any way that I can store the data the first time the page is accessed i.e. reading the data from the database into a recordset and somehow storing this recordset in a session level array or something like that? Mise Le Meas,

Mighty :)
 
You can store your recordsets in session arrays, and then read them each time the page is reloaded.

The syntax for objects (such as recordsets) is:

set session("myRS") = myRS

syntax for regular variables (and arrays) is:

session("myVar") = myVar

It's not a recommended practice to store recordsets in session variables if there is a large amount of traffic on your site. It will seriously affect the performance of your site if there are.

However, if there aren't many users on the site, then it's a really quick and easy way to make data persistent.

good luck! :)
Paul Prewett
 
link9,

Once the recordset is stored in the session variable as above, how do I access it? Do I use array notation or recorset notation. e.g. is it session("myRS").MoveFirst or is it session("myRS")(0) Mise Le Meas,

Mighty :)
 
First copy the session variable to a local variable and then use it:

Code:
set myRs = session("myRs")
myRs.MoveFirst

Yours,

Rob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top