求一分页类的使用方法。
代码如下:
<%
Class Page
Private CurrPage
Private PageN
Private UrlStr
Private TempStr
Private ErrInfo
Private IsErr
Private TotalRecord
Private TotalPage
Public PageRs
Private TempA(11)
Private TempB(8)
'------------------------
Private Sub Class_Initialize()
CurrPage=1 '//默认显示当前页为第一页
PageN=10 '//默认每页显示10条数据
UrlStr= "? "
TempStr= " "
ErrInfo= "ErrInfo: "
IsErr=False
End Sub
Private Sub Class_Terminate()
If IsObject(PageRs) Then
PageRs.Close
Set PageRs=Nothing
End If
Erase TempA
Erase TempB
End Sub
'----------------------
'//获取当前页码
Public Property Let CurrentPage(Val)
CurrPage=Val
End Property
Public Property Get CurrentPage()
CurrentPage=CurrPage
End Property
'//获取每页显示条数
Public Property Let PageNum(Val)
PageN=Val
End Property
Public Property Get PageNum()
PageNum=PageN
End Property
'//获取URL
Public Property Let Url(Val)
UrlStr=Val
End Property
Public Property Get Url()
Url=UrlStr
End Property
'//获取模板
Public Property Let Temp(Val)
TempStr=Val
End Property
Public Property Get Temp()
Temp=TempStr
End Property
'------------------------
Public Sub Exec(Sql,ConnObj)
On Error Resume Next
Set PageRs=Server.CreateObject( "ADODB.RecordSet ")
PageRs.CursorLocation = 3 '使用客户端游标,可以使效率提高
PageRs.PageSize = PageN '定义分页记录集每页显示记录数
PageRs.Open Sql,ConnObj,0,1
If Err.Number <> 0 Then
Err.Clear
PageRs.Close
Set PageRs=Nothing