日期:2010-09-27 浏览次数:20993 次
这个分页使用的是0游标,也就是Rs.Open Sql,Conn,0,1。但是感觉也快不了多少,10
万条数据的分页时间300多豪秒之间
<%
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
ErrInfo=ErrInfo&"建立或打开记录集错误..."
IsErr=True
Response.Write ErrInfo
Response.End
End If
TotalRecord=PageRs.RecordCount'//如果为0呢?
If TotalRecord>=1 Then
'----------------------------------------------------------------------------开始
'//计算总页数,Ps,为什么不用PageRs.PageCount呢?
'If TotalRecord Mod PageN=0 Then
'TotalPage=PageRs.RecordCount\PageN
'Else
'TotalPage=PageRs.RecordCount\PageN
'TotalPage=Abs(Int(TotalPage))
'End If
TotalPage=PageRs.PageCount
'//处理当前接收页码,默认的为1,所以不是数字类型的都会为1
If IsNumeric(CurrPage) Then
CurrPage=CLNg(CurrPage)
&nbs