![]() |
#2
yms1232012-02-12 16:11
你在显示时对bof或eof判断一下即可
<!--#include file="../conn.asp" --> <% Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select * from lunbo ORDER BY id DESC" rs.Open sql,conn,1,1 %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <style type="text/css"> <!-- .STYLE1 { font-size: 24px; color: #0066FF; } --> </style> </head> <body> <table width="780" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="630" height="40" align="center" bgcolor="#00FFFF"><span class="STYLE1">图 片 后 台 编 辑</span></td> <td colspan="3" align="center" bgcolor="#00FFFF" > <% if not rs.eof then%> <a href="htj-lunb.asp?id=<% =rs("id")%>">添 加</a> <%else%> <a href="htj-lunb.asp">添 加</a> <% end if%> </td> </tr> <% if rs.EOF and rs.BOF then response.write else Do Until rs.EOF %> <tr> <td align="center"><img src="<%=rs("pic1")%>" width="100" height="70"> </td> <td align="center"><a href="hscgd-lunb.asp?id=<%=rs("id") %>">删 除</a></td> <td align="center"><a href="hxg-lunb.asp?id=<%=rs("id") %>">修 改</a></td> </tr> <% rs.MoveNext Loop end if %> </table> </body> </html> |
问题描述:做网站后台管理,有" 添加","修改","删除"3个页面,当数据库中的数据表无记录时,3个页面都无法访问,提示:
"错误类型:
ADODB.Field (0x80020009)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。"
这样,搞得我在"添加"页面无法再次输入新的数据,只好把数据库打开,在数据表中重新输入.我想请教大家的是:当记录集查询到数据表中无数据时,能否使后台编辑页面显示,点击"添加"进入添加页面,同时,提示"暂时无数据"等类似的语句.多谢
附:后台图片编辑页面
<!--#include file="../conn.asp" -->
<%
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from lunbo ORDER BY id DESC"
rs.Open sql,conn,1,1
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 24px;
color: #0066FF;
}
-->
</style>
</head>
<body>
<table width="780" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="630" height="40" align="center" bgcolor="#00FFFF"><span class="STYLE1">图 片 后 台 编 辑</span></td>
<td colspan="3" align="center" bgcolor="#00FFFF" ><a href="htj-lunb.asp?id=<% =rs("id")%>">添 加</a></td>
</tr>
<%
if rs.EOF and rs.BOF then
response.write
else
Do Until rs.EOF %>
<tr>
<td align="center"><img src="<%=rs("pic1")%>" width="100" height="70"> </td>
<td align="center"><a href="hscgd-lunb.asp?id=<%=rs("id") %>">删 除</a></td>
<td align="center"><a href="hxg-lunb.asp?id=<%=rs("id") %>">修 改</a></td>
</tr>
<% rs.MoveNext
Loop
end if
%>
</table>
</body>
</html>
[ 本帖最后由 tepnidh 于 2012-2-12 18:19 编辑 ]