[thelist] Response.Write versus varHTML = varHTML & "..."

Warden, Matt mwarden at mattwarden.com
Mon Jan 14 15:15:07 CST 2002


On Jan 14, Howard Cheng had something to say about Re: [thelist]..."

>[%
>strSQL = "SELECT ..."
>objRS.Open strSQL, objConn, adOpenStatic, , adCmdText
>iTotal = objRS.RecordCount
>iCount = 0
>
>Dim arText(iTotal)
>While Not objRS.EOF
>         arText(iCount) = objRS("field")
>         iCount = iCount + 1
>         objRS.MoveNext
>Wend
>objRS.Close
>%]
>[html]
>[body]
>[%
>For Each strText In arText
>         Response.Write strText & vbCRLF
>Next
>%]
>[/body]
>[/html]
>
>How do ya like them apples?


Well, they're making me bloated and sluggish!

(psst... that was a performance joke)

((but, please, hold your applause until the end.))

there is NO reason to cycle through the recordset like that, using the
recordcount property and a dimensioned array and a counter,
and... and... etc.

your new best friend: oRecordset.GetRows()

where oRecordset is your recordset object. it returns a two-dimensional
array with the records of the recordset.

HOWEVER...!

in performance tests, this was inferior to other methods when returning
less than 250 rows in the resultset.

with greater than 250 rows, there was quite an improvement in processing
time.

but, since your intent was to keep some certain order in your script
(still not sure EXACTLY what teh objective here is) and you are therefore
limited in options, GetRows() is most definitely your best bet.

having a 2-dim array of a recordset allows for a lot of nifty, compact
coding for complex objectives (of course, the same objective can almost
always be achieved by cycling through a recordset, but it's just not as
cool).

hope this helps some.

--
mattwarden
mattwarden.com






More information about the thelist mailing list