Click to See Complete Forum and Search --> : Using Resultset save() method vs. re-executing again later
kevinp
03-06-2007, 07:05 AM
I have a query which executes and gets assignment ids, groups, marks etc which I display in the first table of a page. Later on I need this information again to calculate average marks for assignments.
I have seen the save() method listed on w3schools but is this easier/more efficient to use than just re-executing the query again later in the script?
russell
03-06-2007, 08:50 AM
should assign the results to variables instead of either method if it is in the same script.
kmalone
03-06-2007, 09:17 AM
http://www.w3schools.com/ado/met_rs_getrows.asp
Check out that article, it's a command i use alot when i'm working with large datasets with repitition (like you have).
usually, when first building a page i'll do something like this:
--initialize database object and recordset--
'check for empty recordset then
RsArray=Rs.getrows
Rs.close
response.write "<table border=1>"
for i=0 to ubound(RsArray,2)
response.write "<tr>"
for j=0 to ubound(RsArray,1)
response.write "<td>"&RsArray(j,i)&" </td>"
next
response.write "</tr>"
next
response.write "</table>"
Secondly, i usually replace the 'j' loop with variable declarations such as:
var1=RsArray(0,i)
var2=RsArray(1,i)
etc... to clean up the code and make it more readable.
the next time you need to access that information its all still there without another round trip to your database.