注册 登录
编程论坛 ASP技术论坛

为什么总显示错误?

niubiya001 发布于 2007-11-18 23:57, 447 次点击

<%
set rs=server.CreateObject("ADODB.recordset")
sql="select * from message order by id desc"
rs.pagesize=4
rs.open sql,conn,2,1
if not rs.eof or not rs.eof then
%>
<body bgcolor="#CCFFFF" leftmargin="40" rightmargin="40" topmargin="10">
<table align="center" border="1">
<tr height="20"><th colspan="7">留言内容</th></tr>
<%
totalput=rs.recordcount
perpagesize=rs.pagesize
currpage=request.QueryString("currpage")
if currpage="" then
currpage=1
elseif currpage<1 then
currpage=1
else currpage=clng(currpage)
end if

if currpage>rs.pagecount then
currpage=rs.pagecount
end if
if not isnumeric(currpage) then
currpage=1
end if
if (totalput mod perpagesize)=0 then
n=totalput\perpagesize
else n=totalput\perpagesize+1
end if
if n=0 then
n=1
end if
rs.move(currpage-1)*perpagesize
i=0
do while not rs.eof and i<perpagesize
%>
<tr height="20" bgcolor="#9999FF"><td width="10%">留言人</td><td width="10%"><%=rs("username")%></td>
<td width="10%">留言时间</td><td width="10%"><%=rs("messagetime")%></td><td width="10%">邮箱<%=rs("email")%></td><td width="10%">qq</td><td width="10%"><%=rs("qq")%></td></tr>

<tr height="20"><td width="10%">标题</td><td colspan="6"><%=rs("title")%></td></tr>

<tr height="20"><td colspan="7">留言内容</td></tr>

<tr height="45"><td colspan="7"><%=rs("message")%></td></tr>

<%
i=i+1
rs.movenext
loop
end if
%>
<tr height="10"><td colspan="7">
<%
k=currpage
if k<>1 then %>
<a href="displaymessage.asp?currpage=1">首页</a>
<a href="displaymessage.asp?currpage=<%=k-1%>">上一页</a>
<%else %>
首页 上一页
<% end if %>
<%
if k<>n then

%>
<a href="displaymessage.asp?currpage=<%=n+1%>">下一页</a>
<a href="diaplaymessage.asp?currpage=<%=n%>">尾页</a>
<% else
%>
下一页&nbsp;&nbsp;尾页
<%end if%>

4 回复
#2
madpbpl2007-11-19 01:29
if not rs.eof or not rs.eof then
这句有问题,改成
if not rs.eof or not rs.bof then
还有,楼主,具体报什么错,哪里报错,标红显示并贴出出错信息,这样大家才好帮你分析。
#3
hmhz2007-11-19 08:10
if not rs.eof or not rs.eof then
改成
if not(rs.eof and rs.bof) then
#4
kira0072007-11-19 11:50
if not rs.eof or not rs.eof then
这句 直接改为

do while not rs.eof

下面的 END IF 去掉
<%
i=i+1
rs.movenext
loop
end if
%>
#5
hmhz2007-11-19 14:52
楼上的,下面已经有分页的 do while not rs.eof and i&lt;perpagesize 你上面再加do while not rs.eof 不出错才怪
1