麻烦各位,初级分页问题出现0x80020009错误,我也找不到错误

aspnewuser 2007-10-10 09:55:59
错误类型:
ADODB.Field (0x80020009)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

<%
pgsize=16
Set conn=server.CreateObject("adodb.connection")
conn.open "Provider=microsoft.jet.oledb.4.0;data source="&server.mappath("db2.mdb")
Set rs1=server.CreateObject("adodb.recordset")
rs1.open "select UserRegName,RegNickName,UserAddTime from UserInfo order by UserRegID asc",conn,3,1,1
rs1.PageSize=pgsize
int_totalrecord=rs1.RecordCount
If int_totalrecord Mod pgsize = 0 Then
intpagecount=CInt(int_totalrecord / pgsize)
Else
intpagecount=CInt((int_totalrecord / pgsize)+1)
End If
intpage=request.querystring("intpage")
If RegExpTest("^([1-9]+)([0-9]*)$",intpage)<>True Then intpage=1
If intpage>intpagecount Then intpage=intpagecount
rs1.AbsolutePage=intpage

Function RegExpTest(patrn, strng)
Dim regEx, retVal
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = False
retVal = regEx.Test(strng)
RegExpTest = retVal '不符合false,符合为true
End Function
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
</head>

<body>
<table>
<%
If rs1.eof And rs1.bof Then
response.write "无信息"
Else
For iloop=1 To pgsize
%>
<tr><td><%=rs1("UserRegName")%></td><td><%=rs1("RegNickName")%></td><td><%=rs1("UserAddTime")%></td></tr>
<%
rs1.MoveNext
Next
End If%>
</table>
<table border="1" cellpadding="1" cellspacing="0" bordercolordark="#000000" bordercolorlight="#FFFFFF">
<tr>
<td><%For dloop=1 To intpagecount%> <a href="?intpage=<%=dloop%>"><%=dloop%></a> <%Next%></td>
</tr>
</table></body>
</html>
<%
rs1.close
Set rs1=Nothing
Set conn=Nothing
%>
...全文
126 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Go 旅城通票 2007-10-11
  • 打赏
  • 举报
回复
<%
If rs1.eof And rs1.bof Then
response.write "无信息"
Else '更改为另一种方式显示数据
do while not rs1.eof
% >
<tr > <td > <%=rs1("UserRegName")% > </td > <td > <%=rs1("RegNickName")% > </td > <td > <%=rs1("UserAddTime")% > </td > </tr >
<%
if i >=pgsize then exit do '判断是否大于等于pgsize,为真退出循环
rs1.MoveNext
loop'========================更正这里,不是wend
End If% >
Go 旅城通票 2007-10-11
  • 打赏
  • 举报
回复
<%
pgsize=16
Set conn=server.CreateObject("adodb.connection")
conn.open "Provider=microsoft.jet.oledb.4.0;data source="&server.mappath("db2.mdb")
Set rs1=server.CreateObject("adodb.recordset")
rs1.open "select UserRegName,RegNickName,UserAddTime from UserInfo order by UserRegID asc",conn,3,1,1
rs1.PageSize=pgsize
int_totalrecord=rs1.RecordCount
If int_totalrecord Mod pgsize = 0 Then
intpagecount=CInt(int_totalrecord / pgsize)
Else
intpagecount=CInt((int_totalrecord / pgsize)+1)
End If
intpage=request.querystring("intpage")
If RegExpTest("^([1-9]+)([0-9]*)$",intpage) < >True Then intpage=1
If intpage >intpagecount Then intpage=intpagecount
'rs1.AbsolutePage=intpage '=============去掉这句
'改为下面的
if intpage<>1 then rs1.moveto (intpage-1)*pgsize '移动记录集

Function RegExpTest(patrn, strng)
Dim regEx, retVal
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = False
retVal = regEx.Test(strng)
RegExpTest = retVal "不符合false,符合为true
End Function
% >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" >
<head >
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" / >
<title >Untitled Document </title >
</head >

<body >
<table >
<%
If rs1.eof And rs1.bof Then
response.write "无信息"
Else '更改为另一种方式显示数据
do while not rs1.eof
% >
<tr > <td > <%=rs1("UserRegName")% > </td > <td > <%=rs1("RegNickName")% > </td > <td > <%=rs1("UserAddTime")% > </td > </tr >
<%
if i>=pgsize then exit do'判断是否大于等于pgsize,为真退出循环
rs1.MoveNext
wend
End If% >
</table >
<table border="1" cellpadding="1" cellspacing="0" bordercolordark="#000000" bordercolorlight="#FFFFFF" >
<tr >
<td > <%For dloop=1 To intpagecount% >  <a href="?intpage= <%=dloop% >" > <%=dloop% > </a >  <%Next% > </td >
</tr >
</table > </body >
</html >
<%
rs1.close
Set rs1=Nothing
Set conn=Nothing
% >
aspnewuser 2007-10-10
  • 打赏
  • 举报
回复
楼上的意思是我没搜索啊?我搜了,可没找到解决方法,所以就提问了啊

补充:上边的代码有点问题,就是计算总页数,改过来还是错误依旧

If int_totalrecord Mod pgsize = 0 Then
intpagecount=Int(int_totalrecord / pgsize)
Else
intpagecount=Int(int_totalrecord / pgsize)+1
End If
若白师妹 2007-10-10
  • 打赏
  • 举报
回复
会问问题?
aspnewuser 2007-10-10
  • 打赏
  • 举报
回复
照五楼的说法不出现错误提示,但是分页不起作用,每次打开页面时显示第一页内容正确,但点任意一页只显示数据库的最后11条记录,数据库中总共有91条记录
Go 旅城通票 2007-10-10
  • 打赏
  • 举报
回复
<%
If rs1.eof And rs1.bof Then
response.write "无信息"
Else
For iloop=1 To pgsize
if not rs1.bof then'加个是否到达数据集底部的判断
% >
<tr > <td > <%=rs1("UserRegName")% > </td > <td > <%=rs1("RegNickName")% > </td > <td > <%=rs1("UserAddTime")% > </td > </tr >
<%
rs1.MoveNext
end if
Next
End If% >
Go 旅城通票 2007-10-10
  • 打赏
  • 举报
回复
<%
If rs1.eof And rs1.bof Then
response.write "无信息"
Else
For iloop=1 To pgsize '这个pgsize应该再加上判断是否这个页的数据是否为pgsize条,如果小于pgsize,肯定出错
% >
<tr > <td > <%=rs1("UserRegName")% > </td > <td > <%=rs1("RegNickName")% > </td > <td > <%=rs1("UserAddTime")% > </td > </tr >
<%
rs1.MoveNext
Next
End If% >
aspnewuser 2007-10-10
  • 打赏
  • 举报
回复
大家帮忙啊

28,391

社区成员

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

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