Results 1 to 3 of 3

Thread: Which way is best.....

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Question

    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

  2. #2
    Addicted Member
    Join Date
    Nov 2000
    Location
    UK
    Posts
    164
    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
    ASP, SQL, VB6, Java Script and dubious guitar playing skills.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343
    Thanks Alex,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width