asp记录分页显示(ACCESS数据库,百万条记录)

时间:2021-07-13 23:49:07
这个是要查询的投票记录的表

Id 自动编号 
user_id 被投票人ID 
username 被投票人姓名 
Pingjia 评价 (1满意 2基本满意 3 不满意)
explain 说明 (255字符以内)
Vote_ip 投票IP地址 
Vote_datetime 投票日期时间 

上线3天,目前投票记录2万条,如果按照目前的速度到结束时估计能达到百万级。我没接触过这么多的数据量。

数据记录一条也不能删除,尽管我也认为没有什么意义。

显示页面只有后台能看到,每页50条,分页显示的。下面的代码测试通过(当时数据很少),可是现在已经明显不行了,第一页很快,但是点击下一页,速度太慢了,乃至没有反应了。哪位朋友有改进办法。

这是我写的代码:
-------------------------------------
<%
dim rs,page_max,sum_page,sum_vote_log,page
page_max = 50 '每页显示记录数

'获取记录总数,赋于sum_vote_log
set rs = conn.execute("select count(id) as sum_vote_log from ballot")
sum_vote_log = rs("sum_vote_log")
set rs = nothing

'取得总页数(也是最后一页)
if sum_vote_log = 0 then
sum_vote_log = 1
end if
sum_page = int(sum_vote_log/page_max)'总页数 
if sum_vote_log mod page_max > 0 then
sum_page = sum_page + 1
end if

'判断传来的page数是否正确
if isnumeric(request.QueryString("page")) = false then  
call infogo("页码有误,将为您转向第一页!","vote_log.asp?page=1")
end if
if request.QueryString("page")="" then
page = 1
else
page = cint(request.QueryString("page"))
end if 
if page < 1 or page > sum_page then  
call infogo("页码有误,将为您转向第一页!","vote_log.asp?page=1")
end if 
'查询指定页数的记录,并存于数组arr_vote_log中
dim id
dim arr_vote_log,sql
dim arr_vote_log_len,i,last_vote_log'数组中记录数,i,最后一条记录下标
dim tr_bgcolor,tr_bgcolor_i
if page = 1 then
sql = "select top "&page_max&" * from ballot order by id desc"
else  
sql = "select top "&page_max&" * from ballot where (id < (select min(id) from ballot where id in (select top "&page_max * (page - 1)&" id from ballot order by id desc))) order by id desc"
end if
set rs = conn.execute(sql)
if not(rs.bof and rs.eof) then
arr_vote_log = rs.getrows
arr_vote_log_len = Ubound(arr_vote_log,2)
else
arr_vote_log_len = 0
end if

set rs = nothing
if arr_vote_log_len >= 0 then
last_vote_log = page_max - 1
if last_vote_log > arr_vote_log_len then '判断每页记录数是否大于数组的下标
last_vote_log = arr_vote_log_len
end if
for i = 0 to last_vote_log
  '以下为显示投票记录 省略…………
  next
else
  ……
end if
%>

这个系统已经开始投票,只能改进。哪位朋友有好的解决方案,帮帮忙。我分不多,对不住大家。

13 个解决方案

#1


Access不要用selec top 100 from * where id < (select min(id) from (***))这样的方式分页,直接用RecordSet自带的分页功能分页

#2


朋友,能解释下吗?
很感谢你!

#3


使用西楼冷月的分页类2.0吧。操作百万条数据。。

#4


引用 1 楼 mocom 的回复:
Access不要用selec top 100 from * where id < (select min(id) from (***))这样的方式分页,直接用RecordSet自带的分页功能分页


selec top 100 from * where id < (select min(id) from (***))
这怎么用??没见过。。难道我落后了?

不是:selec top 100 * from 表名 where id < (select min(id) from (***))

这个吗啊??

#5


selec top 100 from * where id < (select min(id) from (***))
是抽象描述,*是通配符,表示任意表,这句sql只是说明个格式,这种格式在SQL Server中分页飞快,在Access中就不行了,Access用ADODB.RecordSet自带的分页功能

#6


弱弱的问一下   access  支持  百万记录吗

#7


ACCESS数据库如果超过2,3W的话,就考虑升级到SQL server吧

#8


学习学习咯

#9


牛逼!Access支持百万记录操作,怎么弄得,教教我。

#10


给你一个高效分页类:

<%

'
'程序特点
'本程序主要是对数据分页的部分进行了封装,而数据显示部份完全由用户自定义,
'支持URL多个参数,支持多表关联查询,支持多字段排序
'
'使用说明
'程序参数说明
'PapgeSize      定义分页每一页的记录数
'GetRS       返回经过分页的Recordset此属性只读
'GetConn      得到数据库连接
'GetField       得到查询字段
'GetTbName       得到表名
'GetWhere       得到条件
'GetOrder       得到排序

'程序方法说明
'ShowPage      显示分页导航条,唯一的公用方法
'
'===================================================================

'Const Btn_First="<font face=""webdings"">9</font>"  '定义第一页按钮显示样式
'Const Btn_Prev="<font face=""webdings"">3</font>"  '定义前一页按钮显示样式
'Const Btn_Next="<font face=""webdings"">4</font>"  '定义下一页按钮显示样式
'Const Btn_Last="<font face=""webdings"">:</font>"  '定义最后一页按钮显示样式

Const Btn_First="首页"  '定义第一页按钮显示样式
Const Btn_Prev="上一页"  '定义前一页按钮显示样式
Const Btn_Next="下一页"  '定义下一页按钮显示样式
Const Btn_Last="末页"  '定义最后一页按钮显示样式

Class Cls_PageView
Private XD_PageCount,XD_Conn,XD_Rs,XD_SQL,XD_TbName,XD_Where,XD_Order,XD_Key,XD_PageSize,XD_Field,XD_total,Str_errors,int_curpage,str_URL,int_totalPage,int_totalRecord,XD_sURL,swhere,sorder


'=================================================================
'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

'=================================================================
'GetRS 属性
'返回分页后的记录集
'=================================================================
Public Property Get GetRs()
 Set XD_Rs=Server.createobject("adodb.recordset")
 XD_Rs.PageSize=PageSize
 If XD_Where = "" Then
  swhere = ""
 Else
  swhere = " where "&XD_Where
 End If
 If XD_Order = "" Then
  sorder = " order by "&XD_Key&" desc"
 Else
  sorder = " order by "&XD_Order
 End If
 
 XD_total = XD_Conn.ExeCute ("select count("& XD_Key &") from "& XD_TbName &swhere)(0)'总记录数
 XD_PageCount = abs(int(-abs(XD_total/PageSize)))'总页数
 If Int_curpage>XD_PageCount Then Int_curpage=XD_PageCount
 XD_SQL = "select "&XD_Field&" from "&XD_TbName&swhere&sorder
 XD_Rs.Open XD_SQL,XD_Conn,1,1
 XD_Rs.absoluteposition=XD_Rs.absoluteposition+((abs(int_curpage)-1)*PageSize)
 Set GetRs=XD_Rs
End Property

'================================================================
'GetConn  得到数据库连接
'
'================================================================ 
Public Property Let GetConn(obj_Conn)
 Set XD_Conn=obj_Conn
End Property

'================================================================
'GetTbName   得到表名
'
'================================================================
Public Property Let GetTbName(str_TbName)
 XD_TbName=str_TbName
End Property
'================================================================
'GetField   得到表名
'
'================================================================
Public Property Let GetField(str_Field)
 XD_Field=str_Field
End Property

'================================================================
'GetWhere   得到条件
'
'================================================================
Public Property Let GetWhere(str_Where)
 XD_Where=str_Where
End Property
'================================================================
'GetKey   得到主键
'
'================================================================
Public Property Let GetKey(str_Key)
 XD_Key=str_Key
End Property

'================================================================
'GetOrder   得到排序
'
'================================================================
Public Property Let GetOrder(str_Order)
 XD_Order=str_Order
End Property

'==================================================================
'Class_Initialize 类的初始化
'初始化当前页的值
'
'================================================================== 
Private Sub Class_Initialize
 '========================
 '设定一些参数的黙认值
 '========================
 XD_PageSize=10  '设定分页的默认值为10
 '========================
 '获取当前面的值
 '========================
 If Trim(Request("Page"))="" or Not(IsNumeric(Trim(Request("Page")))) Then
  int_curpage=1
 Else
  Int_curpage=CInt(Trim(Request("Page")))
 End If
 If Int_curpage<1 Then Int_curpage=1
End Sub

'====================================================================
'ShowPage  创建分页导航条
'有首页、前一页、下一页、末页、还有数字导航
'
'====================================================================
Public Sub ShowPage()
 Dim str_tmp
 XD_sURL = GetUrl()
 int_totalRecord=XD_total
 int_TotalPage=XD_PageCount
 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=ShowNextLast'下一页、末页
 response.write str_tmp
 str_tmp=ShowPageInfo
 response.write str_tmp
 str_tmp=GetPageEnd
 response.write str_tmp
 response.write ""
End Sub

'====================================================================
'ShowFirstPrv  显示首页、前一页
'
'
'====================================================================
Private Function ShowFirstPrv()
 Dim Str_tmp,int_prvpage
 If Int_curpage=0 or Int_curpage=1 Then
  str_tmp=Btn_First&" "&Btn_Prev
 Else
  int_prvpage=Int_curpage-1
  str_tmp="<a href="""&XD_sURL & "1" & """>" & Btn_First&"</a> <a href=""" & XD_sURL & CStr(int_prvpage) & """>" & Btn_Prev&"</a>"
 End If
 ShowFirstPrv=str_tmp&"&nbsp;"
End Function

'====================================================================
'ShowNextLast  下一页、末页
'
'
'====================================================================
Private Function ShowNextLast()
 Dim str_tmp,int_Nextpage
 If Int_curpage>=int_totalpage Then
  str_tmp=Btn_Next & " " & Btn_Last
 Else
  Int_NextPage=int_curpage+1
  str_tmp="<a href=""" & XD_sURL & CStr(int_nextpage) & """>" & Btn_Next&"</a> <a href="""& XD_sURL & CStr(int_totalpage) & """>" &  Btn_Last&"</a>"
 End If
 ShowNextLast=str_tmp&"&nbsp;"
End Function


'====================================================================
'ShowPageInfo  分页信息
'更据要求自行修改
'
'====================================================================
Private Function ShowPageInfo()
 Dim str_tmp
 str_tmp="页次:<font color=#ff0000>"&int_curpage&"</font>/<font color=#ff0000>"&int_totalpage&"</font>页 共<font color=#ff0000>"&int_totalrecord&"</font>条记录 <font color=#ff0000>"&XD_PageSize&"</font>条/每页"
 ShowPageInfo=str_tmp
End Function

'==================================================================
'GetPageEnd  下拉跳转
'根据要求自行修改
'
'==================================================================
Public Function GetPageEnd()
Dim str_tmp
str_tmp = "<input name=""thepage"" type=""text"" id=""thepage"" value="""& int_curpage &""" size=""3"">" & vbCrLf
str_tmp = str_tmp & "<a href=""javascript:gourl();"">GO</a>" & vbCrLf
str_tmp = str_tmp & chr(13) & "<" & "script language=JavaScript>"
str_tmp = str_tmp & chr(13) & "function gourl(){"
str_tmp = str_tmp & chr(13) & "document.location=""" & XD_sURL &"""+document.all.thepage.value+"""";"
str_tmp = str_tmp & chr(13) & "}"
str_tmp = str_tmp & chr(13) & "<" & "/script>"
GetPageEnd=str_tmp
End Function

'==================================================================
'GetURL  得到当前的URL
'更据URL参数不同,获取不同的结果
'
'==================================================================
Private Function GetURL()
 Dim strurl,str_url,i,j,search_str,result_url
 search_str="Page="
 
 strurl=Request.ServerVariables("URL")
 Strurl=split(strurl,"/")
 i=UBound(strurl,1)
 str_url=strurl(i)'得到当前页文件名
 
 str_params=Trim(Request.ServerVariables("QUERY_STRING"))
 If str_params="" Then
  result_url=str_url & "?Page="
 Else
  If InstrRev(str_params,search_str)=0 Then
   result_url=str_url & "?" & str_params &"&Page="
  Else
   j=InstrRev(str_params,search_str)-2
   If j=-1 Then
    result_url=str_url & "?Page="
   Else
    str_params=Left(str_params,j)
    result_url=str_url & "?" & str_params &"&Page="
   End If
  End If
 End If
 GetURL=result_url
End Function

'====================================================================
' 设置 Terminate 事件。
'
'====================================================================
Private Sub Class_Terminate  
 XD_RS.close
 Set XD_RS=nothing
End Sub
'====================================================================
'ShowError  错误提示
'
'
'====================================================================
Private Sub ShowError()
 If str_Error <> "" Then
  Response.Write("" & str_Error & "")
  Response.End
 End If
End Sub
End class
%>

#11


使用例子:

<%
'创建对象
Set mm=new Cls_PageView
With mm
'设置每一页的记录条数据为30条
.PageSize=30
'得到数据库连接
.GetConn=Conn
.GetTbName="table1"
.GetField="id,aaaa,bbbb,cccc"
.GetWhere=""
.GetKey="id"
.GetOrder="id asc"
End With
'返回Recordset
Set Rs=mm.GetRs()
For i=1 to mm.PageSize
If Rs.EOF or Rs.BOF Then Exit For
bgColor="#DFEFFF"
If i Mod 2=0 Then bgColor="#FFFFFF"
%>  
  <tr bgcolor="<%=bgColor%>"> 
    <td width="60"><%=Rs(0)%></td>
    <td width="150"><%=Rs(1)%></td>
    <td width="*"><%=left(Rs(2),20)%></td>
    <td width="150"><%=Rs(3)%></td>
  </tr>
<%
Rs.MoveNext
Next
%>  

#12


本帖最后由 chinmo 于 2010-08-15 16:45:29 编辑
首页 上一页 下一页 末页 页次:1/16263页 共487862条记录 30条/每页 GO
本页面执行时间:93.750毫秒


  首页 上一页 下一页 末页 页次:5/16263页 共487862条记录 30条/每页 GO
本页面执行时间:31.250毫秒
这是我测试例子的结果

#13


恩,很好,学习了.

#1


Access不要用selec top 100 from * where id < (select min(id) from (***))这样的方式分页,直接用RecordSet自带的分页功能分页

#2


朋友,能解释下吗?
很感谢你!

#3


使用西楼冷月的分页类2.0吧。操作百万条数据。。

#4


引用 1 楼 mocom 的回复:
Access不要用selec top 100 from * where id < (select min(id) from (***))这样的方式分页,直接用RecordSet自带的分页功能分页


selec top 100 from * where id < (select min(id) from (***))
这怎么用??没见过。。难道我落后了?

不是:selec top 100 * from 表名 where id < (select min(id) from (***))

这个吗啊??

#5


selec top 100 from * where id < (select min(id) from (***))
是抽象描述,*是通配符,表示任意表,这句sql只是说明个格式,这种格式在SQL Server中分页飞快,在Access中就不行了,Access用ADODB.RecordSet自带的分页功能

#6


弱弱的问一下   access  支持  百万记录吗

#7


ACCESS数据库如果超过2,3W的话,就考虑升级到SQL server吧

#8


学习学习咯

#9


牛逼!Access支持百万记录操作,怎么弄得,教教我。

#10


给你一个高效分页类:

<%

'
'程序特点
'本程序主要是对数据分页的部分进行了封装,而数据显示部份完全由用户自定义,
'支持URL多个参数,支持多表关联查询,支持多字段排序
'
'使用说明
'程序参数说明
'PapgeSize      定义分页每一页的记录数
'GetRS       返回经过分页的Recordset此属性只读
'GetConn      得到数据库连接
'GetField       得到查询字段
'GetTbName       得到表名
'GetWhere       得到条件
'GetOrder       得到排序

'程序方法说明
'ShowPage      显示分页导航条,唯一的公用方法
'
'===================================================================

'Const Btn_First="<font face=""webdings"">9</font>"  '定义第一页按钮显示样式
'Const Btn_Prev="<font face=""webdings"">3</font>"  '定义前一页按钮显示样式
'Const Btn_Next="<font face=""webdings"">4</font>"  '定义下一页按钮显示样式
'Const Btn_Last="<font face=""webdings"">:</font>"  '定义最后一页按钮显示样式

Const Btn_First="首页"  '定义第一页按钮显示样式
Const Btn_Prev="上一页"  '定义前一页按钮显示样式
Const Btn_Next="下一页"  '定义下一页按钮显示样式
Const Btn_Last="末页"  '定义最后一页按钮显示样式

Class Cls_PageView
Private XD_PageCount,XD_Conn,XD_Rs,XD_SQL,XD_TbName,XD_Where,XD_Order,XD_Key,XD_PageSize,XD_Field,XD_total,Str_errors,int_curpage,str_URL,int_totalPage,int_totalRecord,XD_sURL,swhere,sorder


'=================================================================
'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

'=================================================================
'GetRS 属性
'返回分页后的记录集
'=================================================================
Public Property Get GetRs()
 Set XD_Rs=Server.createobject("adodb.recordset")
 XD_Rs.PageSize=PageSize
 If XD_Where = "" Then
  swhere = ""
 Else
  swhere = " where "&XD_Where
 End If
 If XD_Order = "" Then
  sorder = " order by "&XD_Key&" desc"
 Else
  sorder = " order by "&XD_Order
 End If
 
 XD_total = XD_Conn.ExeCute ("select count("& XD_Key &") from "& XD_TbName &swhere)(0)'总记录数
 XD_PageCount = abs(int(-abs(XD_total/PageSize)))'总页数
 If Int_curpage>XD_PageCount Then Int_curpage=XD_PageCount
 XD_SQL = "select "&XD_Field&" from "&XD_TbName&swhere&sorder
 XD_Rs.Open XD_SQL,XD_Conn,1,1
 XD_Rs.absoluteposition=XD_Rs.absoluteposition+((abs(int_curpage)-1)*PageSize)
 Set GetRs=XD_Rs
End Property

'================================================================
'GetConn  得到数据库连接
'
'================================================================ 
Public Property Let GetConn(obj_Conn)
 Set XD_Conn=obj_Conn
End Property

'================================================================
'GetTbName   得到表名
'
'================================================================
Public Property Let GetTbName(str_TbName)
 XD_TbName=str_TbName
End Property
'================================================================
'GetField   得到表名
'
'================================================================
Public Property Let GetField(str_Field)
 XD_Field=str_Field
End Property

'================================================================
'GetWhere   得到条件
'
'================================================================
Public Property Let GetWhere(str_Where)
 XD_Where=str_Where
End Property
'================================================================
'GetKey   得到主键
'
'================================================================
Public Property Let GetKey(str_Key)
 XD_Key=str_Key
End Property

'================================================================
'GetOrder   得到排序
'
'================================================================
Public Property Let GetOrder(str_Order)
 XD_Order=str_Order
End Property

'==================================================================
'Class_Initialize 类的初始化
'初始化当前页的值
'
'================================================================== 
Private Sub Class_Initialize
 '========================
 '设定一些参数的黙认值
 '========================
 XD_PageSize=10  '设定分页的默认值为10
 '========================
 '获取当前面的值
 '========================
 If Trim(Request("Page"))="" or Not(IsNumeric(Trim(Request("Page")))) Then
  int_curpage=1
 Else
  Int_curpage=CInt(Trim(Request("Page")))
 End If
 If Int_curpage<1 Then Int_curpage=1
End Sub

'====================================================================
'ShowPage  创建分页导航条
'有首页、前一页、下一页、末页、还有数字导航
'
'====================================================================
Public Sub ShowPage()
 Dim str_tmp
 XD_sURL = GetUrl()
 int_totalRecord=XD_total
 int_TotalPage=XD_PageCount
 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=ShowNextLast'下一页、末页
 response.write str_tmp
 str_tmp=ShowPageInfo
 response.write str_tmp
 str_tmp=GetPageEnd
 response.write str_tmp
 response.write ""
End Sub

'====================================================================
'ShowFirstPrv  显示首页、前一页
'
'
'====================================================================
Private Function ShowFirstPrv()
 Dim Str_tmp,int_prvpage
 If Int_curpage=0 or Int_curpage=1 Then
  str_tmp=Btn_First&" "&Btn_Prev
 Else
  int_prvpage=Int_curpage-1
  str_tmp="<a href="""&XD_sURL & "1" & """>" & Btn_First&"</a> <a href=""" & XD_sURL & CStr(int_prvpage) & """>" & Btn_Prev&"</a>"
 End If
 ShowFirstPrv=str_tmp&"&nbsp;"
End Function

'====================================================================
'ShowNextLast  下一页、末页
'
'
'====================================================================
Private Function ShowNextLast()
 Dim str_tmp,int_Nextpage
 If Int_curpage>=int_totalpage Then
  str_tmp=Btn_Next & " " & Btn_Last
 Else
  Int_NextPage=int_curpage+1
  str_tmp="<a href=""" & XD_sURL & CStr(int_nextpage) & """>" & Btn_Next&"</a> <a href="""& XD_sURL & CStr(int_totalpage) & """>" &  Btn_Last&"</a>"
 End If
 ShowNextLast=str_tmp&"&nbsp;"
End Function


'====================================================================
'ShowPageInfo  分页信息
'更据要求自行修改
'
'====================================================================
Private Function ShowPageInfo()
 Dim str_tmp
 str_tmp="页次:<font color=#ff0000>"&int_curpage&"</font>/<font color=#ff0000>"&int_totalpage&"</font>页 共<font color=#ff0000>"&int_totalrecord&"</font>条记录 <font color=#ff0000>"&XD_PageSize&"</font>条/每页"
 ShowPageInfo=str_tmp
End Function

'==================================================================
'GetPageEnd  下拉跳转
'根据要求自行修改
'
'==================================================================
Public Function GetPageEnd()
Dim str_tmp
str_tmp = "<input name=""thepage"" type=""text"" id=""thepage"" value="""& int_curpage &""" size=""3"">" & vbCrLf
str_tmp = str_tmp & "<a href=""javascript:gourl();"">GO</a>" & vbCrLf
str_tmp = str_tmp & chr(13) & "<" & "script language=JavaScript>"
str_tmp = str_tmp & chr(13) & "function gourl(){"
str_tmp = str_tmp & chr(13) & "document.location=""" & XD_sURL &"""+document.all.thepage.value+"""";"
str_tmp = str_tmp & chr(13) & "}"
str_tmp = str_tmp & chr(13) & "<" & "/script>"
GetPageEnd=str_tmp
End Function

'==================================================================
'GetURL  得到当前的URL
'更据URL参数不同,获取不同的结果
'
'==================================================================
Private Function GetURL()
 Dim strurl,str_url,i,j,search_str,result_url
 search_str="Page="
 
 strurl=Request.ServerVariables("URL")
 Strurl=split(strurl,"/")
 i=UBound(strurl,1)
 str_url=strurl(i)'得到当前页文件名
 
 str_params=Trim(Request.ServerVariables("QUERY_STRING"))
 If str_params="" Then
  result_url=str_url & "?Page="
 Else
  If InstrRev(str_params,search_str)=0 Then
   result_url=str_url & "?" & str_params &"&Page="
  Else
   j=InstrRev(str_params,search_str)-2
   If j=-1 Then
    result_url=str_url & "?Page="
   Else
    str_params=Left(str_params,j)
    result_url=str_url & "?" & str_params &"&Page="
   End If
  End If
 End If
 GetURL=result_url
End Function

'====================================================================
' 设置 Terminate 事件。
'
'====================================================================
Private Sub Class_Terminate  
 XD_RS.close
 Set XD_RS=nothing
End Sub
'====================================================================
'ShowError  错误提示
'
'
'====================================================================
Private Sub ShowError()
 If str_Error <> "" Then
  Response.Write("" & str_Error & "")
  Response.End
 End If
End Sub
End class
%>

#11


使用例子:

<%
'创建对象
Set mm=new Cls_PageView
With mm
'设置每一页的记录条数据为30条
.PageSize=30
'得到数据库连接
.GetConn=Conn
.GetTbName="table1"
.GetField="id,aaaa,bbbb,cccc"
.GetWhere=""
.GetKey="id"
.GetOrder="id asc"
End With
'返回Recordset
Set Rs=mm.GetRs()
For i=1 to mm.PageSize
If Rs.EOF or Rs.BOF Then Exit For
bgColor="#DFEFFF"
If i Mod 2=0 Then bgColor="#FFFFFF"
%>  
  <tr bgcolor="<%=bgColor%>"> 
    <td width="60"><%=Rs(0)%></td>
    <td width="150"><%=Rs(1)%></td>
    <td width="*"><%=left(Rs(2),20)%></td>
    <td width="150"><%=Rs(3)%></td>
  </tr>
<%
Rs.MoveNext
Next
%>  

#12


本帖最后由 chinmo 于 2010-08-15 16:45:29 编辑
首页 上一页 下一页 末页 页次:1/16263页 共487862条记录 30条/每页 GO
本页面执行时间:93.750毫秒


  首页 上一页 下一页 末页 页次:5/16263页 共487862条记录 30条/每页 GO
本页面执行时间:31.250毫秒
这是我测试例子的结果

#13


恩,很好,学习了.