NextRecordset and GetRows are two attributes of the recordset to improve the speed of the batch query is very effective, you may use very little, share the use of these two methods:
GetRows Method: The recordset Recordset is extracted into a two-dimensional array, the behavior of our recordset data is transferred to the array, we can disconnect the record set early, no longer use the source data operation, Rs.movnext, while not Rs.eof and so on can be omitted.
NextRecordset Method: to submit multiple queries at once and form multiple recordset result sets, provide a way to move from the current working recordset to the next recordset. It is mainly used in the case of a result set formed by multiple select. Examples are as follows:
Query records
Set Rs=conn.execute ("Select Ca1,ca2,ca3,ca4 from TableA select Cb1,cb2,cb3,cb4,cb5 from TableB")
' After execution, a result set of two select is generated, and the recordset for the first select is currently active.
Arra=rs. GetRows ' Gets the first two-dimensional array of query results
Set Rs=rs. NextRecordset ' Activates the next recordset
Arrb=rs. GetRows ' gets a two-dimensional array of the results of the second query
Set rs=nothing ' Frees database objects
In this way, all of our data on the database extraction completed, the earliest time to release the database resources.
Note that the GetRows method gets the array, the first dimension represents the column, and the second dimension represents the row.
For i=0 to ubound (arra,2)
Response.Write ("<tr>")
Response.Write ("<td> Field 1:" &arra (i,0) & "</td>")
Response.Write ("<td> Field 2:" & ARRA (i,1) & "</td>")
Response.Write ("<td> Field 3:" &arra (i,2) & "</td>")
Response.Write ("<td> field 4:" &arra (i,3) & "</td>")
Response.Write ("</tr>")
Next
Response.Write ("</table>")
' Second Select Table loop
Response.Write (' <p> table two:</p> <table> ")
For i=0 to ubound (arrb,2)
Response.Write (" <tr> ")
Response.Write ("<td> Field 1:" &arrb (i,0) & "</td>")
Response.Write ("<td> Field 2:" & ARRB (i,1) & "</td>")
Response.Write ("<td> Field 3:" &arrb (i,2) & "</td>")
Response.Write ("<td> field 4:" &arrb (i,3) & "</td>")
Response.Write ("<td> field 5:" &ARRB (i,4) & "</td>")
Response.Write ("</tr>")
Next
Response.Write ("</ Table> ")
Advantages:
1, the use of NextRecordset, you can handle multiple SELECT statements to send the resulting set of results, reduce network traffic, must speed up!
2, using GetRows to extract the recordset into the array (memory operation, so the recordset can not be too large) with the memory of the array work, and save the EOF, MoveNext and other judgments, faster!
3, the most important, we use the two, one-time will all the data, quickly disconnect the database and destroy the established recordset database objects, greatly reduce network traffic! Performance naturally to improve a lot!
Article Source: http://www.joyiu.com/article.asp?id=56