Improve dynamic paging performance in ASP

zhaozj2021-02-11  185

Improve dynamic paging performance in ASP

Zhang Li Feng Zhang

SUMMARY There are now many articles that use ASP to implement dynamic paging, and the method is similar, that is, each time the ADO returns the original data to meet the specified page in the condition recordset. However, in actual engineering applications, the amount of raw data is usually very large, and the processing of the original data is slow. If the original data is transferred once, it will seriously affect the performance of the application run. There are two main ways to solve the above problems: a way is to fix the query conditions relatively, using relatively fixed query conditions to process the original data, generate a small amount of intermediate library, and each query is operated. This will increase the performance of the program, but will affect the flexibility of the program, and the Server side will need to process the original data to be maintained. Another way is the result of saving the query at the Server side. This cannot improve the performance of the query, but the Server end can respond quickly when the Client ends. The implementation of the first pathway is relatively simple, and this paper introduces the second way to implement the method. Implementation Saves the query result of the Server end in a dynamic array, that is, declare a two-dimensional dynamic array during the session_onstart process. When the Server side receives the application submitted by the Client, first determine whether the application is the condition query or change, if the conditional query is discriminated, if the query condition is different from the query condition of the last submit, if the query is executed, save the query results in In this array, then the contents of the first page will be returned to the Client side, otherwise it will return the contents of the corresponding page directly from the array.

Program implementation 1. Define two-dimensional arrays and other variables SUB session_onstart Dim Tempdb () Redim preserve tempdb (1,2) session ("storedarray) = Tempdb 'Defines a session array session (" ipagecount ") = 0 session (" ipageno ") = 0 ... End Sub 2. Call a stored procedure to return data Sub GetRecordSet (strBbmc, strKssj, strZzsj, strNodeCode, strFxzl) 'parameter report name and respective constraints select case strBbmc case "Transaction Summary" strCnn = "PROVIDER = MSDASQL; dsn = sqldb; uid = sa ; pwd = 123456; database = vlog; "Set objcnn = Server.CreateObje (" ADODB.Connection ") objcnn.CommandTimeout = 9999999 objcnn.ConnectionTimeout = 99999999 objcnn.CursorLocation = adUseClient objcnn.Open strCnn 'open connection Set objRs = Server. CreateObject ( "ADODB.Recordset") objRS.PageSize = iPageSize objRS.CacheSize = iPageSize objRs.Open "sszhatmlog '" & strKssj & "', '" & strZzsj & "', '" & strNodeCode & "', '" & Strfxzl & "'", Objcnn, AdoPenStatic, AdlockReadOnly, 1' Perform the stored procedure Returns the query result ... End Sub 3. Save the query results to the dynamic array SUB SAVERECORDSET () if objrs.eof = false damjrs.movelast session ("iFieldCount") = objrs.fields.count session ("ipagecount" = Objrs.pagecount Redim Preserve Temparray ("iRowcount"), session ("ifieldcount") 'TemParray is a two-dimensional dynamic array, redefine its size objrs.movefirst iCount = 0 do while objrs.eof according to record set size False i = iCount 1 for i = 1 to seemparray (iCount, i) = objrs.fields.Item (i-1) .Value next objrs.movenext loop session ("storedarray" = Temparray Objrs .Close else session ("ipagecount") =

0 End if End Sub 4. Displaying recorded contents Sub ShowRecord () ...... LocalArray = session ( "StoredArray") iShowTotal = (iPageCurrent-1) * iPageSize 1 iRowLoop = 1 do while iRowLoop <= iPageSize and iShowTotal <= session ( "iRowCount") Response .Write ("") for i = 1 to session ("iFieldcount") Response.write ("" & Localarray (IshowTotal, i)) Next Response.write ("") ISHOWTOL = iShowTotal 1 irowloop = irowloop 1 loop response.write ("") if ipagecurrent <> 1 and ipagecurrent

> Rear Page <% Else if ipagecurrent <> 1 THEN>

New Post(0)