Universal Paging Subsidy Category

Source: Internet
Author: User

<%
Class Page
' Universal paging subsidy class conn,rs and other objects themselves closed, this class regardless of: D
Private page_num, Page_max, table, ID, shows, sort, where, order
Private Page_count, Record_count
Private Conn, RS

Private Sub Class_Initialize
Shows = "*"
End Sub

Private Sub Class_Terminate

End Sub

Private Sub Init
' Initialization parameters
Dim T_where

If where <> "" Then t_where = "where" & Trim (where)

Record_count = conn. Execute ("Select COUNT (*) from" & Table & T_where) (0)

Page_count = Record_count/page_max

If record_count Mod page_max > 0 Then page_count = page_count + 1

End Sub

Private Function Get_sql
' Return to SQL
Dim t_where, Top, T_order

If page_count > Page_num Or record_count Mod page_max = 0 Then
top = Page_max
Else
top = Record_count Mod Page_max
End If

If UCase (Order) = "DESC" Then
T_order = "ASC"
Else
T_order = "DESC"
End If

If where <> "" Then t_where = "where" & Trim (where)

Get_sql = "Select Temp." & ID &, Data. "& Join (Split (Shows,", "),", Data. ") &" From ("& _
' Select Top ' & Top & ' * FROM (' & _
' Select Top ' & Page_num * Page_max & ' & ID & ' from ' & Table & T_where & _
"ORDER BY" & Sort & "" & Order & _
") as temp" & _
"ORDER BY" & Sort & "" & T_order & _
") as temp" & _
"INNER JOIN" & Table & "As Data" & _
"On temp." & id & = Data. "& ID & _
"ORDER by temp." & ID & "" & Order

End Function

Public Property Let Set_page (T_n)
' Set Number of pages
If Trim (t_n) = "" or IsNull (t_n) or not IsNumeric ("0" & T_n) Then
Page_num = 1
Else
Page_num = Int (t_n)
End If
End Property

Public Sub Set_conn (ByRef t_o)
' Set the Conn object
Set conn = T_o
End Sub

Public Property Let Set_max (T_n)
' Set the number of displays
Page_max = T_n
End Property

Public Property Let Set_table (T_v)
' Set table
Table = T_v
End Property

Public Property Let set_id (T_v)
' Set ID field
id = t_v
End Property

Public Property Let Set_shows (T_v)
' Set display fields
Shows = T_v
End Property

Public Property Let Set_sort (T_v)
' Set sort fields
Sort = T_v
End Property

Public Property Let Set_where (T_v)
' Set qualifications
where = T_v
End Property

Public Property Let Set_order (T_v)
' Set sort style
Order = T_v
End Property

Public Property Get PageCount
' Return pages
PageCount = Page_count
End Property

Public Property Get RecordCount
' Returns the total number of records
RecordCount = Record_count
End Property

Public Property Get Pagenum
' Return to current page
Pagenum = Page_num
End Property

Public Function Open
' Initialize the parameter, open the Recordset, and return the Recordset object
Call Init ' initialization parameters
Set RS = conn. Execute (Get_sql)
Set Open = rs
End Function

End Class
%>

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.