关于三寸金莲的资料:sql 查询 验证问题

来源:百度文库 编辑:高考问答 时间:2024/04/28 21:29:03
if ac="adduser" then
set rsc=server.createobject("adodb.recordset")
rsc.open "select * from user where username='"&request.Form("username")&"'",conn,1,1
ck=rsc("username")
set rsc=nothing
if ck<>"" then
msg=msg&"<br>"&"已经被人注册"
response.Redirect("reg.asp?msg="&msg)
end if

在rsc.open "select * from user where username='"&request.Form("username")&"'",conn,1,1
老是出错 是怎么回事啊

conn 的问题把

试试
if ac="adduser" then
sql="select * from user where username='"&request.Form("username")&"'"
rsc=execute(sql)
if not( rsc.eof and rsc.bof )then
msg=msg&"<br>"&"已经被人注册"
response.Redirect("reg.asp?msg="&msg)
end if
end if

user是保留字加一个[]就可以了
rsc.open "select * from [user] where [username]='"&request.Form("username")&"'",conn,1,1

rsc.open "select * from user where username='"&request.Form("username")&"'",conn,3,2
搞定

问题应该出在
ck=rsc("username")

你输入一个已存在的用户名,应该不会出错.
就算不是这里的错,你这里也不应该这样做判断.