conn.execute 查找记录时出错

来源:百度知道 编辑:UC知道 时间:2024/07/05 02:44:02
数据库中的表admin中有数据。
但是我使用:
Set CONN = Server.CreateObject("ADODB.CONNection")
CONN.Open MM_conn_STRING
SQL="select * from [admin] where account='"&account&"'"
Set rs=CONN.Execute(SQL)
Response.Write(rs(account))
If rs.Eof and rs.Bof Then
Response.write("<script>alert('对不起,您的用户名或密码不对。');location.href='login.asp'</script>")
Response.End
END IF
IF NOT rs(account) = Trim(Request.Form("account")) AND rs(password)=Trim(Request.Form("mdpassword")) THEN
response.write("<script>alert('对不起,您的用户名或密码不对。');location.href='login.asp'</script>")
ELSE
name=rs(name)
End IF
Conn.Close
Set Conn= Nothing
-----------------------------------------------------------------
总是提示:800a0cc1|在对应所需名称或序数的集合中,未找到项目。
admin表中有两列:account和password。

错误的意思是,在结果集合里面找不到你需要的字段。
你的代码里面出现了 rs(account) 还有 rs(password)

这样查询是不对的。这个时候,是在查询以account变量所对应的值作为字段名的字段了。改成rs("account"),有好几处,ASP虽然比较简单。楼主还是细心一点比较好。