ASP constructs a paging SQL statement of big data volume.

zhaozj2021-02-16  85

I saw the stored procedure of Tiequan "to achieve a page display of thousands of data!", I feel good, I have changed to the ASP code.

<% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936"%> <% 'tab SQL statements generated code Function GetPageSQL (tblName, fldName, PageSize, PageIndex, OrderType, strWhere) Dim strTemp, strSQL, strOrder' generates a correlation according to the ordering Code if Ordertype = 0 Then Strtemp = "> (Select Max ([" & fldName & "]" Strorder = "Order by [" & fldName & "] ASC" Else Strtemp = "<(Select Min ([[[" & FldName & "Strorder =" Order by ["& fldName &"] DESC "END IF 'is the unsuined statement if it is page 1, if the complex statement IF pageIndex = 1 damp =" "IF strwhere <>" "Ten Strtmp =" WHERE " STRWHERE END IF STRSQL =" SELECT TOP "& PAGESIZE &" * from ["& tblname &"] "" SQL statement strsql = "SELECT TOP" & Pagesize & STRTMP & STRORDER ELSE ' "* From [" & tblname & "] where [" & fldname & "]" & strtemp & _ "from (SELECT TOP" & (PageIndex-1) * Pagesize & "[" & FLDNAME & "] from [" & fldName & "] TBLNAME & "]" IF strwhere <> "" Then strsql = strsql & "where" & strwhere endiffsql = strsql & strOrder & ") as tblTemp)" if strWhere <> "" then strSQL = strSQL & "And" & strWhere end if strSQL = strSQL & strOrder end if GetPageSQL = strSQL 'SQL statement returns End Functionresponse.write (GetPageSQL ( "

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

New Post(0)