大家帮我看看这段代码错在那了

来源:百度知道 编辑:UC知道 时间:2024/05/26 17:38:11
老是出错,提醒 该户名已经存在,请重新填写用户名.

<!--#include file="conn.asp"-->
<%

username= Trim(request.form("username"))
userpassword= Trim(request.form("passwrd"))

set rs=server.CreateObject ("adodb.recordset")
sql="select * from zhuce "
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
response.write"<SCRIPT language=JavaScript>alert('该户名已经存在,请重新填写用户名。');"
response.write"javascript:history.go(-1)</SCRIPT>"
response.end
else
rs.addnew
rs("username")=username
rs("passwrd ")=userpassword

rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>
这个是conn.asp文件

我把sql="select * from zhuce " 改成

sql="select * from zhuce where username='"&username&"'"

sql="select * from zhuce where username='"&username&"'"
在对应所需名称或序数的集合中,未找到项目。

这个错误应该是你的 数据库中 用户名 字段不是username

sql="select * from zhuce where username='"&username&"'"

如果只是sql="select * from zhuce "
就是取全部的记录,几乎肯定是存在记录的了