bbs中分页超过3页就出错,那位帮我看看。可以另外开贴加分

zhouxm 2002-07-23 02:10:58
我做的这个BBS中,定制分页,如果超过3页,就不能够正常显示,到第三页就只显示几条记录,到第四页就出错。具体的代码如下:那位帮我看看,解决后,可以另外开贴送分。

userID=Session("user_ID")

if trim(userID)="" then
row=20
titlelength=0
displaystyle="truename"
textwidth=700

else
strPhysicalPath = Server.Mappath(".")
strDBName = "db.mdb"
Set con = Server.CreateObject("ADODB.Connection")
con.Open "DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL=MS Access;DriverId=25;DefaultDir=" & strPhysicalPath & ";DBQ=" & strPhysicalPath & "\" & strDBName

SQL = "select * from UserInfor t where t.UserID='"&userID&"'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQL, con ,3 ,1

row=rs("DisRows")
titlelength=rs("TitleLength")
displaystyle=rs("DisAuthor")
textwidth=rs("TextWidth")
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>分页显示</TITLE>
<link rel="stylesheet" href="css001.css" type="text/css">
</HEAD>
<BODY bgcolor="#6699cc">
<p align="center">当前显示文件类别:
<SELECT id=select1 name=select1 style="HEIGHT: 22px; WIDTH: 121px">
<OPTION value="all" selected>所有文件</OPTION></SELECT></p>
<%
sql="select * from Article order by ID DESC"
set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open sql, con, 3, 1

pagesize=cint(row)

if objRS.RecordCount<pagesize then
pagesize=objRS.RecordCount
'else
' pagesize=objRS.RecordCount
end if

totalnum=int((objRS.RecordCount/pagesize))

if pagesize<objRS.RecordCount then
totalnum=int((objRS.RecordCount/pagesize)+1)
end if
if pagesize>objRS.RecordCount then
totalnum=int(1)
end if

pagenum=Request.QueryString("page")
pagenum=cint(pagenum)

if pagenum<1 then
pagenum=1
end if

if pagenum>totalnum then
'pagenum=objRS.PageCount
pagenum=totalnum
end if
if pagenum<totalnum and pagenum>1then
pagenum=cint(Request.QueryString("page"))
end if

objRS.AbsolutePage=pagenum
strscriptname=Request.ServerVariables("script_name")

%>
<p align="center">当前类别共有文章:
<%Response.Write(objRS.RecordCount)

Response.Write(totalnum)
%> 篇。本页从第
<%Response.Write((pagenum-1)*pagesize+1) %>

<% if pagenum*pagesize>objRS.RecordCount then
Response.Write(objRS.RecordCount)
else
Response.Write(pagenum*pagesize)
end if
%>
</p>
<p align="center">
<%if pagenum=1 then%>
<<至起始页 <上一页 |
<%else%>
<A href="bbs.asp?page=1"><<至起始页 </a>
<A href="bbs.asp?page=<%=pagenum-1%>"><上一页 |</a>
<%end if%>
<% if pagenum=totalnum then %>
下一页> 至结束页>>
<%else%>
<A href="bbs.asp?page=<%=pagenum+1%>">下一页> </a>
<A href="bbs.asp?page=<%=totalnum%>">至结束页>></a>
<%Response.Write(pagenum)%>
<%end if%>
</p>

<table align="center" border="0">
<tr>
<td align="middle">序号</td>
<td align="middle">作者</td>
<td align="middle">标 题</td>
<td align="middle">发布时间</td>
<td align="middle">回复</td>
</tr>
<% num=(pagenum-1)*pagesize+1%>
<%
if pagenum*pagesize>objRS.RecordCount then
pagesize=(objRS.RecordCount-(pagenum-1)*pagesize)
''else
' pagesize=cint(row)
end if
%>
<%for i=1 to pagesize%>
<tr>
<td align="middle"><%Response.Write(num)%></td>
<td align="middle">
<%
'if StrComp(displaystyle,"truename",0) then
Response.Write(objRS(1))
'else
' Response.Write(objRS(2))
'end if
%>
</td>
<td align="middle">
<%if titlelength=0 then%>
<A href="view.asp?keyword=<%Response.Write(objRS(3))%>"><%Response.Write(objRS(3))%></a>
<%else%>
<A href="view.asp?keyword=<%Response.Write(left(objRS(3),titlelength))%>"><%Response.Write(left(objRS(3),titlelength))%></a>
<%end if%>
 
</td>
<td align="middle">
<%Response.Write(objRS(4))%>
</td>
<td align="middle">
<%Response.Write(objRS(5))%>
</td>
<td align="middle">
<%Response.Write(pagesize)
%>
<%
objRS.MoveNext()
if objRS.EOF then
exit for
end if

num=num+1

next
%>
</tr>
</table>

</BODY>
</HTML>
...全文
82 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
freezwy 2002-07-23
  • 打赏
  • 举报
回复
强烈建议你修改你的程序,你的分页很耗费资源的,参考下面的文章和方法:
http://www.aspsky.net/article/list.asp?id=2469
http://www.aspsky.net/article/list.asp?id=2470
freezwy 2002-07-23
  • 打赏
  • 举报
回复
强烈建议你修改你的程序,你的分页很耗费资源的,参考下面的文章和方法:
http://www.aspsky.net/article/list.asp?id=2469
http://www.aspsky.net/article/list.asp?id=2470
freezwy 2002-07-23
  • 打赏
  • 举报
回复
强烈建议你修改你的程序,你的分页很耗费资源的,参考下面的文章和方法:
http://www.aspsky.net/article/list.asp?id=2469
http://www.aspsky.net/article/list.asp?id=2470
evonne_feng 2002-07-23
  • 打赏
  • 举报
回复
最好给出出错说明
zhouxm 2002-07-23
  • 打赏
  • 举报
回复
UP AND UP!

在加100!!!!!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧