PDA

Click to See Complete Forum and Search --> : Which way is best.....


turfbult
Feb 22nd, 2001, 04:57 AM
Hello again,

I was just wondering which piece of code is best.

1.) Here I select everything I want from my table and then do something like

<%
while not rs.eof
response.write "<tr><td bgcolor='#C7D5D0'>" & rs("cityname") & "</td></tr>"
rs.movenext
wend
%>

2.) Now I'm thinking about first doing my select and populating an array before even reaching the html tags.
From the array I will then build my html table. Something like...

<%
ssql = select * from table
set rs = cnConnect.execute (ssql)
count = 0
while not rs.eof
''populate my array - lets call it arrName
count = count + 1
rs.movenext
wend
%>

<html>
Now I'll build my html table by "reading" thru the array and using the array variables like arrName(count)


Does this make sense - I was just thinking about it. As far as I see/understand this logic I will now have less "hops" to and from the server when doing it using the 2nd option.


I do not want to use getstring etc, partly because I do not know it well enough and also because I create hyperlinks,change bgcolor etc ont the fly - while running thru my rs.

Any help or suggestions please.

Thanks,
T

alexmac
Feb 22nd, 2001, 09:41 AM
I am not cetain but I would of thought setting up an Array would use more resources as even through that row in the database has been written to your page it remains in the array. I wouldnt have thought you would gain much performance by using an array. That array could also get very big.

Altering your select statement may improve peformence however. Do you really need all fields (e.g. select *) in the table.

It is also good practice to close any connections and recordsets when you have finished with them.

Alex

turfbult
Feb 22nd, 2001, 11:07 AM
Thanks Alex,