ASP选择条件如何做

shuyawei 2005-10-22 10:26:37
ADODB.Recordset 错误 '800a0bcd'

BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

我用的是access数据库,每次数据库中没数据的时候就会出这个错...页面上就有这个问题.请问如何加个条件,如果没有数据的时候就不读数据..谢谢~(注用的是ASP)
...全文
98 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuyawei 2005-10-22
  • 打赏
  • 举报
回复
也感谢以上另外几位的帮助,谢谢~`
shuyawei 2005-10-22
  • 打赏
  • 举报
回复
shadow 解决了,非常感谢你的帮助...谢谢...
shadow_chenxy 2005-10-22
  • 打赏
  • 举报
回复
在rs.PageSize=10前面也加上<% if not rs.eof and not rs.bof then %>
在rs.AbsolutePage=page后面加上<% end if %>应该可以了。
shuyawei 2005-10-22
  • 打赏
  • 举报
回复
shadow 我试过了,不行,还是老样子...
shadow_chenxy 2005-10-22
  • 打赏
  • 举报
回复
在 <%for i=1 to rs.PageSize%>
<%if rs.EOF then
exit for
end if%>
前面加上<%
if not rs.eof and rs.bof then
%>
在 <%rs.movenext
next
%>后面加上<% else %><tr><td colspan=4>无记录</td></tr><% end if %>
shuyawei 2005-10-22
  • 打赏
  • 举报
回复
上面是我全部的代码,哪位帮改一下.谢谢~
shuyawei 2005-10-22
  • 打赏
  • 举报
回复
<%set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("hheyzc.mdb")
exec="select * from xsph "
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
rs.PageSize=10
pagecount=rs.PageCount
page=int(request.QueryString ("page"))
if page<=0 then page=1
if request.QueryString("page")="" then
page=1
end if
rs.AbsolutePage=page
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<STYLE>
TD {
FONT-SIZE: 9pt
}
A:link {
FONT-FAMILY: 宋体;
TEXT-DECORATION: none;
color: #333333;
}
A:visited {
FONT-FAMILY: 宋体;
TEXT-DECORATION: none;
color: #333333;
}
A:active {
FONT-FAMILY: 宋体;
TEXT-DECORATION: none;
color: #333333;
}
A:hover {
COLOR: #8DC63F; TEXT-DECORATION: underline
}
body {
margin-top: 0px;
}
.style9 {color: #FFFFFF}
</STYLE>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr bgcolor="F4F2F2">
<td height="21"><div width="41%" align="center">药品名称</div></td>
<td><div width="11%" align="center">规格</div></td>
<td><div width="11%" align="center">单位</div></td>
<td><div width="37%" align="center">生产厂家</div></td>
</tr>
<%for i=1 to rs.PageSize%>
<%if rs.EOF then
exit for
end if%>
<tr>
<td><%=rs("ypmc")%></td>
<td><%=rs("gg")%></td>
<td><%=rs("dw")%></td>
<td><%=rs("cdmc")%></td>
</tr>
<%rs.movenext
next
%>
</table>
</body>
</html>

改了起来啊,哪位帮忙改一下...多谢了~!
solodonut 2005-10-22
  • 打赏
  • 举报
回复
如果要显示多行一般都放到循环里面去
do while not rs.EOF
...........
loop
这样就可以了
if not rs.EOF then
.....
end if这样也可以
shadow_chenxy 2005-10-22
  • 打赏
  • 举报
回复
if not rs.eof and not rs.bof then
for i=1 to rs.recordcount
response.write "记录"
rs.movenext
if rs.eof then exit for
next
else
response.write "无记录"
end if
fantiny 2005-10-22
  • 打赏
  • 举报
回复
recodset对象建立后,

do while not rs.eof

response.write "记录"

rs.movenext
loop
ynxuzhao 2005-10-22
  • 打赏
  • 举报
回复
if rs.eof And rs.bof then
response.write "<script LANGUAGE='javascript'>alert('没有数据');script>"
else
end if
hyjz 2005-10-22
  • 打赏
  • 举报
回复
if not rs.eof then
'// 读数据//
else
'//没有找到需要的数据
end if

28,390

社区成员

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

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