NextRecordset and getRows multi-reed ensemble

zhaozj2021-02-16  158

NEXTRECORDSET and GETROWS are very small! Recently used, good good stuff! It is very effective for improving bulk queries and querying records. NEXTRECORDSET and GETROWS are the two properties of Recordset (attribute or way I often confuse this, unclear, fifth, un) GetRows ---> Take the RecordSet record set into a two-dimensional array, we have the Recordset data The behavior is transferred to the array, can disconnect the record early, no longer use the metadata operation, rs.Movnext, while not qi, etc. can be saved. NextRecordset ----> is a way to submit multiple queries, forming multiple REORDSET results sets, providing a Recordset that leaves the current work, transferring to the second Recordset method! Mainly the result of the result set formed in multiple SELECTs.

Examples are as follows: DIM SQL, RS, ARRA, ARRB, ROWSA, ROWSB '====== Extract Database Library Record ==== (AdoDb.Connection) SQL = "SELECT CA1 , CA2, CA3, CA4 from Tablea "" --------------- Selectasql = SQL & "SELECT CB1, CB2, CB3, CB4, CB5 from Tableb" ------- ------ SelectBSet RS = conn.execute (SQL) 'Execute result will have two Select's result set, the current first SELECT RECORDSET is active ARRA = rs.getrows' ------- --- Get the two-dimensional array of Selecta RecordSet SET RS = RS.NEXTRECORDSET '------------ The most critical step, activate the next Recordsetarrb = rs.getrows' ----- ----- I get the second selectb recordset's two-dimensional array = nothing '--------- Release the database object as soon as possible, close the record set Conn.closset conn = Nothing, all of us About the data dry net extraction of the database is completed, use the earliest time to release the database resource '--------- //' ======== With the acquired ARRA Arrb for page processing, Display data results ====== 'Note, Arra = obtained after getRows, first dimension is the representative column, the second dimension represents row ROWSA = UBOUND (arra, 2)' ---- Extract the second The dimension is equivalent to obtaining the number of records of Recordset, ROWSB = Ubound (Arrb, 2) '-----, extracting the second dimension of Arrb' Data loop: 'The first SELECT table loop Response .write "

" for i = 0 to rowsaresponse.write " response.write"
"& Arra (i, 0) &" "'Tablea.ca1 Response.write" "& Arra (i, 1) &" "'Tablea.ca2 Response.wri TE "" & Arra (I, 2) & "" 'Tablea.ca3 Response.write "" & Arra (i, 3) & ""' Tablea.ca4 response. Write "" Next " 'The second SELECT table loop response.write "" for i =

0 TO ROWSBRESPONSE.WRITE "

Response.write"
"& Arrb (i, 0) &" "'Tableb.cb1 Response.write" "& Arrb (i, 1) &" "'Tableb.cb2 response.write" "& Arrb (i, 2) &" "' Tableb.cb3 Response.write" "& Arrb (i, 3) &" "'Tableb.cb4 response.write" "& Arrb (i, 4) &" "' Tableb.cb5 response.write" "NextResponse.write" '-------- overrem' ============ Small knot ======== This result is clear! (1) Use NextRecordSet to handle the result set of multiple SELECT statements, reduce network traffic, must speed up the speed! Do not use NextRecordset, you will do this: SQL = "SELECT CA1, CA2, CA3, CA4 from Tablea" SET RS = Conn.execute (SQL) SQL = "SELECT CB1, CB2, CB3, CB4, CB5 from Tableb" SET RS = Conn.execute (SQL) (2) Using GetRows to extract the record set into an array (put it in memory, require the record set to not be sea big) work with the array of memory, and save EOF, MOVENEXT and other judgments, who is more fast! Don't say it! (3) The most important, we use the two, one-time, complete all the data, quickly disconnect the database connection and destroy the establishment of the Recordset database object, greatly reduce network traffic! Performance should naturally improve a lot!

转载请注明原文地址:https://www.9cbs.com/read-8340.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.042, SQL: 9