(Author: Green Apple studio compilation, 2000 at 13:45 on November 13)
What is the most effective way to reference record concentration domain values? So far, I use the name of the recordset in the name of the name. This may be a very low efficiency, because each call requires a field. To prove this, the following test is to reference the domain by recording a set of sets of collections (ADO__08.ASP): 'Write Data Do While NOT ObJRS.EOF Response.write (_ "
" & _ "< TD> "& objrs (0) &" td> "& _"
"& objrs (1) &" td> "& _
" & objrs (2) & " TD> "& _"
"& objrs (3) &" td> "& _"
"& objrs (4) &" td> "& _"
"& objrs (5) & " td>" & _ "
" & objrs (6) & " td>" & _ " tr>" _) objrs.movenext loop is as expected, loading Time changes are small (difference may be caused by slight reduction on code). But this technology has brought a significant reduction in effective display time. In the following example, we will specify a separate variable for each domain.
This method avoids all findings in the table (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 FLD5 = ObJRS (4) Set FLD6 = ObJRS (6) 'Write data do while not objrs.eof response.write (_ "
" & _
"& fld0 &" td> "& _"
& FLD1 & "< / TD> "& _"
"& FLD2 &" TD> "& _"
"& FLD3 &" TD> "& _"
"& FLD4 &" TD > "& _"
"& FLD5 &" TD> "& _"
"& FLD6 &" TD> "& _" tr> "_) objrs.movenext loop set FLD0 = Nothing set fld1 = Nothing set fld2 = nothing set fld3 = nothing set fld4 = nothing set fld5 = Nothing set fld6 = Nothing response.write (" table>") end if now, the result of this method is the most Ok. The display time of each record will fall into. 45 milliseconds. Now, all test scripts are configured to have some understanding of the results record set. For example, we have been encoded to domain names in the bar title, separately references the values of these domains.
The following example provides a dynamic solution that circulates in a set of domains, not only data, but also gets the title of the domain (ADO__10.ASP): if Objrs.eof The Response.write ("No Records Found") Else ' Write Headings Response.write ("
) for Each Objfld In Objrs.fields Response.write ("
"& objfld.name &" t> ") Next Response.write (" TR>") 'Write Data Do While NOT ObJRS.EOF Response.write ("
") for Each Objfld In objrs.fields response.write ("
" & objfld.value & "< / TD> ") Next response.write (" tr> ") objrs.movenext loop response.write (" table> ") Endiff can be seen, we have a loss in performance, but this method is Some faster than ADO__07.asp. The following test is in some folds between the last two tests. By saving the domain in a dynamic allocation array, there is only a dynamic flexibility and some loss of performance is also returned.
IF Objrs.eof Then Response.write ("No Records Found") Else Dim FldCount FldCount = Objrs.fields.count Dim Fld () Redim Fld (FLDCOUNT) DIM I for i = 0 To FldCount-1 Set FLD (i) = Objrs (i) Next 'Write Headings Response.write ("
) for i = 0 to fldCount-1 Response.write ("
& FLD (i) .name & " Th> ") Next Response.write (" tr> ") 'Write Data Do While Not Objrs.eof Response.write ("
") for i = 0 to fldCount-1 Response.write ("
"& FLD (I) &" TD> ") Next Response.write (" TR> ") Objrs.Movenext Loop for i = 0 to FldCount-1 Set Fld (i) = Nothing Next Response .Write (" table>") Endiff Although it is not the best value, it is much faster than the previous example, and one advantage is to dynamically expose any record set. In the next test, we will make a thorough change for the previous solution, create an array of loops using the getRows instruction of the record set, not a loop in the recordset itself. Note that after calling getRows, set the record set to Nothing, so that system resources can be released faster.
In addition, pay attention to the first dimension representative domain of the array, the second dimension represents the line (ADO__12.ASP): if objrs.eof kilite ("no records found") objrs.close set objrs = Nothing else 'write headings ...' set array Dim arrRS arrRS = objRS.GetRows 'close recordset early objRS.Close Set objRS = Nothing' write data Dim numRows Dim numFlds Dim row Dim fld numFlds = Ubound (arrRS, 1) numRows = Ubound ( Arrrs, 2) for row = 0 to Numrows Response.write ("
") for flds Response.write ("
" & Arrrs (FLD, ROW) & " td>") Next Response.write (" TR>") Next Response.write (" Table>") End If, you can get the entire recordset and load it into an array by using the getRows instruction. When a particularly large recordset is restored, this method may cause resource problems, but the data is more than much, because the function calls similar to MOVENEXT and EOF detection can be canceled. However, the increase in speed is indeed, because the metadata of the record set is no longer with data. Around this issue, I use the recordset to recover the title name before calling getRows. You can also extract data types and other information in advance. Also note that in our test, performance is only available when using large records. In this part of the final test, let's further use the getString instruction of the record set. This method extracts the entire recordset into a large string, allowing you to specify your own separator (ADO__13.asp): if Objrs.eof Ten Response.write ("No Records Found") Objrs.close Set Objrs = Nothing Else 'Write Headings ...' Set Array Dim Strtable Strtable = Objrs.getstring (2, " TD>
", "
Tr>
") 'Close Recordset Early objrs.close set objrs = Nothing response.write (STRTABLE & " TD> TR> table>") Endiff Although this method is close to the highest level, it is only suitable for the easiest Design because it does not apply to the special situation of data. Observing the time of performing each record before we started this test, the time is always. 83 milliseconds.