RS.BOF AND RS.EOF各位高手,请帮忙

来源:百度知道 编辑:UC知道 时间:2024/07/04 08:08:19
<!--#include file="conn.asp"-->
<%

user=request.form("user")
password=request.form("password")

sql="select * from admin where user='"&user&"' and password='"&password&"' "
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1

If not(rs.bof and rs.eof) Then
session("admin")=rs("user")
session.Timeout=600
rs.close
set rs=nothing
response.redirect("admin.asp")

else
response.write("<script language='javascript'>alert('用户名或者密码不正确!');location='login.asp';</script>")

end if
%>
这段代码出错在哪里呀.弄了一个晚上也不会.晕了.

没有错误啊
要不把 If not(rs.bof and rs.eof) Then
改成if rs.recordcount=0 then
response.write("<script language='javascript'>alert('用户名或者密码不正确!');location='login.asp';</script>")
else
session("admin")=rs("user")
session.Timeout=600
rs.close
set rs=nothing
response.redirect("admin.asp")
end if

user属于系统保留的关键词,请不要做为列名。
如果你已用作列名,SQL请使用下列语句
将user用[user]代替即可。
sql="select * from admin where [user]='"&user&"' and password='"&password&"' "

If not(rs.bof and rs.eof) Then
可以直接写成
if not rs.eof then