这个是ASP的,用的是普通方法,准备再做个取两个端点为准的分页方法,那样效率高些
<% 
Dim strConn,dbConn
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.MapPath("\db.mdb")
Set dbConn=Server.CreateObject("ADODB.connection")
dbConn.open strConn
class page
public sqlText,perPage,currentPage,rs
public pageTotal,recordTotal
Function page(sqlText,perPage)
sqlText=sqlText'(此处赋值可不写,仅做理解提示)接收的sql语句
perPage=perPage'(此处赋值可不写,仅做理解提示)一页多少条内容
Set rs=Server.CreateObject("ADODB.Recordset")
rs.open sqlText,dbConn,1,3
rs.pagesize = perPage ' 设置每页显示的记录数
recordTotal = rs.recordCount ' 记录总数
pageTotal = rs.pagecount ' 页总数 
currentPage=cint(request.QueryString("page"))
If (currentPage="" or currentPage<1) then currentPage=1
If currentPage>pageTotal then currentPage=pageTotal
if not rs.bof and not rs.eof then rs.Absolutepage=currentPage
End Function

Function pagetip()
' currentPage=cint(request.QueryString("page"))
' If (currentPage="" or currentPage<1) then currentPage=1
' If currentPage>pageTotal then currentPage=pageTotal
if Request.ServerVariables("QUERY_STRING")="" then'判断首次进入分页状态时是否存在原有传递参数
links="http://"&Request.ServerVariables("SERVER_NAME")&Request.ServerVariables("URL")&"?"
else
qryStr=split(Request.ServerVariables("QUERY_STRING"),"&") '分解。开始判断是否仅存在分页传递参数
if ubound(qryStr)=0 then '传参字符串分解数组下界值为0,即表示仅一个传递参数,判断是否分页传递参数
if left(qryStr(0),5)<>"page=" then 
links="http://"&Request.ServerVariables("SERVER_NAME")&Request.ServerVariables("URL")&"?"&Request.ServerVariables("QUERY_STRING")&"&"
else 
links="http://"&Request.ServerVariables("SERVER_NAME")&Request.ServerVariables("URL")&"?"
end if
else '传参字符串分解数组下界值不为0,即表示有多个传递参数
for i=0 to ubound(qryStr)
if left(qryStr(i),5)<>"page=" then '判断初始传递是否多参数,不误截取参数
links=StrReverse("http://"&Request.ServerVariables("SERVER_NAME")& Request.ServerVariables("URL")&"?"&Request.ServerVariables("QUERY_STRING")&"&")
else
links=StrReverse("http://"&Request.ServerVariables("SERVER_NAME")& Request.ServerVariables("URL")&"?"&Request.ServerVariables("QUERY_STRING")) '颠倒当前链接
end if
next
for j=1 to len(links)
m=InStr(links,"&")
next
links=Right(links,Len(links)-m)'从第一个&出现处截取字符串
links=StrReverse(links)&"&"
end if
end if response.write "总"&recordTotal&"条 第"&currentPage&"/"&pageTotal&"页 "
response.write "<a style=color:#000000 href="&links&"page=1>首页</a>&nbsp"
response.write "<a style=color:#000000 href="&links&"page="&(currentPage-1)&">上一页</a>&nbsp"
response.write "<a style=color:#000000 href="&links&"page="&(currentPage+1)&">下一页</a>&nbsp"
response.write "<a style=color:#000000 href="&links&"page="&pageTotal&">尾页</a>"
response.write "  <select name=menu1 onchange='window.location=this.options[this.selectedIndex].value'>"
For j=1 to pageTotal
If j=currentPage then
response.write "<option selected=selected value="&links&"page="&j&">"&j&"</option>" 
Else
response.write "<option value="&links&"page="&j&">"&j&"</option>" 
End If
Next
response.write "  </select>"
End Function 
End class
'--------------------------
'用法示例:
'set dbo=new page
'call dbo.page("select * from users",10)
'for i=1 to 10
'if dbo.rs.eof then exit for
'response.Write(dbo.rs("name")&"<br>")
'dbo.rs.movenext
'next
'call dbo.pagetip()
'--------------------------
%>