What is the best choice for improving ASP Performance (cont.)
Source: Internet
Author: User
What is the most effective way to reference a field value in a recordset?
So far, I have used names to refer to the values of the fields in the recordset. This can be a very inefficient approach because each call requires a lookup domain. To prove this, the following test will refer to the domain (ado__08.asp) by a pointer to the collection of fields in the Recordset:
' Write Data
Do as Not objrs.eof
Response.Write (_
"< TR >" & _
"< TD >" & objRS (0) & "</td >" & _
"< TD >" & objRS (1) & "</td >" & _
"< TD >" & objRS (2) & "</td >" & _
"< TD >" & objRS (3) & "</td >" & _
"< TD >" & objRS (4) & "</td >" & _
"< TD >" & objRS (5) & "</td >" & _
"< TD >" & objRS (6) & "</td >" & _
"</tr >" _
)
Objrs.movenext
Loop
As we expected, the load time changes are small (the difference may be due to a slight reduction in code). But this technique has a significant reduction in the time available for effective display.
In the following example, we will specify a separate variable for each field. This method avoids all lookups within the table loop (ado__09.asp):
If objrs.eof Then
Response.Write ("No Records Found")
Else
' Write headings
...
Dim fld0
Dim Fld1
Dim Fld2
Dim fld3
Dim Fld4
Dim Fld5
Dim Fld6
Set fld0 = objRS (0)
Set fld1 = objRS (1)
Set fld2 = objRS (2)
Set fld3 = objRS (3)
Set fld4 = objRS (4)
Set fld5 = objRS (5)
Set Fld6 = objRS (6)
' Write Data
Do as Not objrs.eof
Response.Write (_
"< TR >" & _
"< TD >" & fld0 & "</td >" & _
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service