特警是特种部队吗:无法验证用户已经存在(asp代码)

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 09:35:59
<%
username= trim(request.form("username") )
password= trim(request.form("password1"))
realname=trim(request.form("realname"))
sex=trim(request.form("sex"))
email=trim(request.form("email"))
tishi=trim(request.form("tishi"))
daan=trim(request.form("daan1"))
bzhu=trim(request.form("bzhu"))
set conn=createobject("adodb.connection")
set rs=createobject("adodb.recordset")
w=server.MapPath("Connections/wangjingui/13237059329/wang.mdb")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&w
sql1="SELECT * from user1 where 用户名='"&username&"'"
rs.open sql1,conn,1,1
response.Write "<div>"&rs.eof&"</div>"
response.Write "<div>"&rs.bof&"</div>"
response.write rs.recordcount
if rs.recordcount<>0then
response.Write "该用户已经存在<a href=zhuce.html>返回 </a>"
end if
if rs.recordcount=0 then
rs.close()
set rs=nothing
conn.close
set conn=nothing
set conn=createobject("adodb.connection")
set rs=createobject("adodb.recordset")
w=server.MapPath("Connections/wangjingui/13237059329/wang.mdb")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&w
rs.open "user1",conn,3,2
rs.addnew
rs("用户名")=username
rs("密码")=password
if realname<>"" then
rs("真实姓名")=realname
end if
if sex<>"" then
rs("性别")=sex
end if
if email<>"" then
rs("邮箱")=email
end if
if tishi<>"" then
rs("密码提示问题")=tishi
end if
if daan<>"" then
rs("密码提示问题的答案")=daan
end if
if bzhu<>"" then
rs("备注")=bzhu
end if
rs.update
if err then
response.write("保存出错<a href=zhuce.html>返回")
else
response.write("保存成功<a href=index.asp>返回登陆")
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

response.Write "<div>"&rs.eof&"</div>"
response.Write "<div>"&rs.bof&"</div>"
response.write rs.recordcount

但第一次注册刷新时候rs.eof rs.bof rs.recordcount 都为ture true 0
但是 第二次时 不管输入什么用户rs.eof rs.bof rs.recordcount 都为false false 1

看看这几句:
set rs=createobject("adodb.recordset")
w=server.MapPath("Connections/wangjingui/13237059329/wang.mdb")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&w
rs.open "user1",conn,3,2
因为你后面用这一句又打开了一个rs,所以前面的rs.eof rs.bof rs.recordcount 将为false false 1.

将后面的"rs"都改为"rs1"试试!