ASP constructs the paging SQL statement of large data quantity

Source: Internet
Author: User
Pagination | data | statement 1<% @Language = "VBScript" Codepage = "936"%>
2<%
3 ' Paging SQL statement generates code
4Function Getpagesql (Tblname,fldname,pagesize,pageindex,ordertype,strwhere)
5 Dim Strtemp,strsql,strorder
6 ' Generate related code according to sort method
7 If ordertype = 0 Then
8 strtemp = "> (select Max ([& Fldname &])"
9 Strorder = "ORDER BY [" & Fldname & "] ASC"
Ten Else
One strtemp = "< (select Min ([& Fldname &])"
Strorder = "ORDER BY [" & Fldname & "] Desc"
End If
14
15 ' If page 1th there is no need for complex statements
If PageIndex = 1 Then
strtemp = ""
If strwhere <> "" Then
strtmp = "Where" & strwhere
End If
strSQL = "SELECT Top" & PageSize & "* from [" & Tblname & "]" & strtmp & Strorder
If it's not the 1th page, construct the SQL statement
strSQL = "SELECT Top" & PageSize & "* from [" & Tblname & "] Where [" & Fldname & "]" & Strtemp & _
"From" (Select Top & (PageIndex-1) * PageSize & ["& Fldname &"] from ["& Tblname ; "]"
If strwhere <> "" Then
num strSQL = strSQL & "Where" & strwhere
End If
28



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.