NextRecordset and GetRows method of ASP

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

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 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 1 2 3 4 5 6 Set Rs=conn.execute ("Select Ca1,ca2,ca3,ca4 from TableA select Cb1,cb2,cb3,cb4,cb5 from TableB") ' Holds The row will produce a result set of two select, and the recordset for the first select is currently active. Arra=rs. GetRows ' Gets the first query result of the two-dimensional array set rs=rs. NextRecordset ' Activates the next recordset Arrb=rs. GetRows ' The two-dimensional array set rs=nothing ' that gets the second query result frees the database object

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.

Output Results 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ' First select table's Circulation Response.Write ("<p> table:</p> <table> ") 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 (more code) please visit: http://www.joyiu.com

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.