asp分页奇怪问题
症状:rs=120条 如果每页显示10条或者10条以上 那么能从第1页翻倒12页
如果每页显示8条 分页就是15页 那么只能翻倒7页。 如果每页6条 那么只能翻倒10页。
函数:
Sub Pagination(objRS,Page_Size,PageUrl)
objRS.PageSize=Page_Size
objRS.AbsolutePage=Page
If PageUrl <> " " Then
PageUrl=PageUrl& " "
Else
PageUrl= "? "
End If
If Page <=1 Then
Response.Write "[首页][上一页] "
Else
Response.Write "[ <a href= ' "&PageUrl& "Page=1 '> 首页 </a> ] "
Response.Write "[ <a href= ' "&PageUrl& "Page= "&(Page-1)& " '> 上一页 </a> ] "
End If
If Page> =objRS.PageCount Then
Response.Write "[下一页][尾页] "
Else
Response.Write "[ <a href= ' "&PageUrl& "Page= "&(Page+1)& " '> 下一页 </a> ] "
Response.Write "[ <a href= ' "&PageUrl& "Page= "&objRS.PageCount& " '> 尾页 </a> ] "
End If
Response.Write "转到第 <input type= 'text ' name= 'page ' size= '3 ' maxlength= '5 ' value= ' " &Page & " ' onKeyPress= " "if (event.keyCode==13) window.location= ' " & PageUrl & "page= " & " '+this.value; " " '> 页 <input type= 'submit ' value= 'Enter '> "
Response.Write "[共 <Font color= 'Red '> <b> "&objRS.RecordCount& " </b> </Font> 条记录] "
Response.Write "[页 <Font color= 'Red '> "&Page& " </Font> / "&objRS.PageCount& "页] "
End Sub
调用
Call Pagination(rs,11, "ssyh.asp?buserid= "&id& "& ")
其中11就是每页显示条数。
------解决方案--------------------我一直用的分页
<%
SoFia_DbName= "jiaoyou " '修改此处为你的SQL Server 数据库名称
YourServer = "seven " '修改此处为你的Sql Server数据库地址
YourUid = "sa " '修改此处为你的数据库用户名
YourPassword = "struts " '修改此处为你的数据库密码
Connstr = "Driver={SQL Server};Server= "&YourServer& ";Uid= "&YourUid& ";Pwd= "&YourPassword& ";Database= "&SoFia_DbName
Set Conn=Server.CreateObject( "ADODB.CONNECTION ")
' On Error Resume Next
Conn.Open Connstr
If Err <> 0 Then
err.Clear
Set Conn = Nothing
Response.Write " <div align=center> <br> <br> <br> 连接SqlServer数据库出错,请检查相关设置…… </div> "
Respo