asp的通用數(shù)據(jù)分頁類
2024-05-04 11:01:46
供稿:網(wǎng)友
(原創(chuàng))<!--#include file="Conn.asp" -->
通用數(shù)據(jù)分頁類
通用分頁類,以后寫分頁顯示數(shù)據(jù)時就輕松多啦.直接調(diào)用此類,然后再Execute即可以取得當前頁的所有數(shù)據(jù).
此類所做的工作是只取得當前頁的數(shù)據(jù),和總頁數(shù)和總記錄數(shù)等等數(shù)據(jù).
ASP代碼:
<%
'/*****************************分頁顯示類**************************
'/* 作者:哇哇魚
'/* 日期:2004年11月18日
'/* 作用:取得某一頁的數(shù)據(jù)并返回給外部
'/* 說明示例:
'/* Dim MyPage=New PageClass
'/* MyPage.Conn=Conn '設(shè)置連接對象
'/* MyPage.PageSize=20 '設(shè)置一頁顯示多少條數(shù)據(jù) (默認為10條)
'/* MyPage.CurPage=2 '設(shè)置當前要顯示的頁碼
'/*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'/* MyPage.TableName="Member" '設(shè)置表名
'/* MyPage.Fields="ID,MemberName,MemberPass" '設(shè)置顯示字段列表
'/* MyPage.Condition="ID>100" '設(shè)置查詢條件
'/* MyPage.OrderBy="ID DESC" '設(shè)置排序條件(一定要設(shè)置該屬性)
'/* Set PageRs=MyPage.Execute '返回當前第2頁的數(shù)據(jù)(RecordSet對象),如果出錯則返回Nothing值
'/*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'/*'以上的定義也可以用以下的方法:ExecuteBy("表名","字段列表","查詢條件","排序條件")
'/* Set PageRs=MyPage.ExecuteBy("Member","ID,MemberName,MemberPass","ID>100","ID DESC")
'/*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'/* PageCount=MyPage.PageCount '返回頁碼總數(shù)
'/* RecordCount=MyPage.RecordCount '返回記錄總數(shù)
'/* NextPage=MyPage.NextPage '返回下頁的頁碼
'/* PrePage=MyPage.PrePage '返回上一頁的頁碼
'/*****************************************************************
Class PageClass
Private Connection '連接數(shù)據(jù)庫的外部Connection對象
Private Rs