Public Property Get GetRs()
Set XD_Rs=Server.createobject("adodb.recordset")
XD_Rs.PageSize=PageSize
XD_Rs.Open XD_SQL,XD_Conn,1,1
If not(XD_Rs.eof and XD_RS.BOF) Then
If int_curpage>XD_RS.PageCount Then
int_curpage=XD_RS.PageCount
End If
XD_Rs.AbsolutePage=int_curpage
End If
Set GetRs=XD_RS
End Property
=============================================
'GetConn 得到数据库连接
'
'=============================================
Public Property Let GetConn(obj_Conn)
Set XD_Conn=obj_Conn
End Property
'=============================================
'GetSQL 得到查询语句
'
'==============================================
Public Property Let GetSQL(str_sql)
XD_SQL=str_sql
End Property
'===============================================
'PageSize 属性
'设置每一页的分页大小
'===============================================
Public Property Let PageSize(int_PageSize)
If IsNumeric(Int_Pagesize) Then
XD_PageSize=CLng(int_PageSize)
Else
str_error=str_error & "PageSize的参数不正确"
ShowError()
End If
End Property
Public Property Get PageSize
If XD_PageSize="" or (not(IsNumeric(XD_PageSize))) Then
PageSize=10
Else
PageSize=XD_PageSize
End If
End Property
'========================
'设定一些参数的黙认值
'========================
XD_PageSize=10 '设定分页的默认值为10
'========================
'获取当前面的值
'========================
If request("page")="" Then
int_curpage=1
ElseIf not(IsNumeric(request("page"))) Then
int_curpage=1
ElseIf CInt(Trim(request("page")))<1 Then
int_curpage=1
Else
Int_curpage=CInt(Trim(request("page")))
End If
End Sub
Public Sub ShowPage()
Dim str_tmp
int_totalRecord=XD_RS.RecordCount
If int_totalRecord<=0 Then
str_error=str_error & "总记录数为零,请输入数据"
Call ShowError()
End If
If int_totalRecord="" Then
int_TotalPage=1
Else
If int_totalRecord mod PageSize =0 Then
int_TotalPage = CLng(int_TotalRecord / XD_PageSize * -1)*-1
Else
int_TotalPage = CLng(int_TotalRecord / XD_PageSize * -1)*-1+1
End If
End If
If Int_curpage>int_Totalpage Then
int_curpage=int_TotalPage
End If
'=====================================================
'显示分页信息,各个模块根据自己要求更改显求位置
'=====================================================
response.write "
str_tmp=ShowFirstPrv '显示首页、前一页
response.write str_tmp
str_tmp=showNumBtn '数字导航
response.write str_tmp
str_tmp=ShowNextLast '下一页、末页
response.write str_tmp
str_tmp=ShowPageInfo
response.write str_tmp
response.write ""
end Sub
到这里类的功能才算完整(为了节省版面,我有些方法没有放上去,再下面附上全部完整代码)写一个简单页面测试一下
<%
’把分页类包含进来
set conn = server.CreateObject("adodb.connection")
conn作者: 78129414 时间: 2007-4-28 17:10