Set rs= cn.Execute ("select psword,zuantai from apply where applynum='"&applynum&"'") if rs.EOF or rs.BOF then response.write"无此注册号!" 当表中没有输入的那条记录是就会出错, 错误类型: (0x80020009) 发生意外。 /caxun.asp, 第 20 行 谁知道这是怎么回事? 怎么去判断这种没记录的返回结果是什么?
那是哪里错了,我全部贴出来
<body>
<%
applynum=request("applynum")
password=request("password")
dim cn
set cn =server.createobject("adodb.connection")
cn.connectionstring="driver={sql server};server=127.0.0.1;database=db;uid=sa;pwd=123"
cn.open
Set rs= cn.Execute ("select psword,zuantai from apply where applynum='"&applynum&"'")
pas=Replace(rs(0)," ","")
%>
<%
if rs.EOF or rs.BOF then
response.write"无此注册号!"
elseif not(rs.Eof) and not(rs.bof) then
if pas<>password then
response.write"密码错误!"
elseif pas=password and isnull(rs(1)) then
response.write"还未审核,请等待!"
elseif pas=password and not(isnull(rs(1))) then
response.write rs(1)
else response.write "未知错误!"
end if
end if
%>
试试这个:
Set rs= cn.Execute ("select count(*) from apply where applynum='"&applynum&"'")
if rs(0) = 0 then
……
也就是说,先根据条件取数据,看是否取到的数据条数为“0”
出错的可能原因在于,rs为空时,本身调用rs就出错,也就是说,rs.eof这时调用rs出错
试试看吧!
我的是oracle 别的数据库是不是用count(*)也不是非常清楚。