库中找不到该记录,但没出现报错语句

Bluebamboo 2002-07-22 11:13:14
我想让程序实现若在库中找不到该记录,报错,代码如下,但当库中找不到该记录时,页面上是什么都没有,而不是我所期望的报"无资料"的语句,请教!

mysql="select dwmc from mytable where xm='"& name &"'" &" and xh='" & code & "'"
on error resume next
set rst=cnn.execute(mysql,1,1)
%>
<html>
<head>
<title>查询系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
if err.number<>0 then
response.write"hihi"
response.write "<font color='#66CC66' size='5' face='隶书'>无资料</font>"
response.end
end if
do while not (rst.bof and rst.eof)
rst.close
set rst=nothing
cnn.close
set cnn=nothing
%>
...全文
5 点赞 收藏 6
写回复
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cmsoft 2002-07-22
<%
if rst.eof then
response.write "<font color='#66CC66' size='5' face='隶书'>无资料</font>"
else
do while not (rst.bof and rst.eof)
repsponse.write rs("xm")
rst.movenext
loop
end if
rst.close
set rst=nothing
cnn.close
set cnn=nothing
%>
回复
cmsoft 2002-07-22
<%
if rst.eof then
response.write "<font color='#66CC66' size='5' face='隶书'>无资料</font>"
else
do while not (rst.bof and rst.eof)
repsponse.write rs("xm")
rst.movenext
loop
end if
rst.close
set rst=nothing
cnn.close
set cnn=nothing
%>
回复
cmsoft 2002-07-22
<%
if rst.eof then
response.write "<font color='#66CC66' size='5' face='隶书'>无资料</font>"
else
do while not (rst.bof and rst.eof)
repsponse.write rs("xm")
rst.movenext
loop
end if
rst.close
set rst=nothing
cnn.close
set cnn=nothing
%>
回复
gshope 2002-07-22
if err.number<>0 then

改成
if rst.eof then
回复
gshope 2002-07-22
if err.number<>0 then

改成
if rst.eof then
回复
blackcatiii 2002-07-22
无资料不是出错!
你可以用
if rst.eof and rst.bof then
response.write "无资料"
else
do while not rst.eof
response.write "详细资料在此显示"
rst.movenext
loop
end if
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告