样判断用户名是否重复?---我的代码有错,但不知错在哪请高手指正

qq52668 2006-06-13 11:45:35
<%
dim licence,company,trade,town,company_info,licence_date,deputy,workers,money,phone,fax,mail,address,note,conn
licence = dealInputString(request.Form("licence"))
company = dealInputString(request.Form("company"))
trade = dealInputString(request.Form("trade"))
town = dealInputString(request.Form("town"))
company_info = dealInputString(request.Form("company_info"))
licence_date = dealInputString(request.Form("licence_date"))
deputy = dealInputString(request.Form("deputy"))
workers = dealInputString(request.Form("workers"))
money = dealInputString(request.Form("money"))
phone = dealInputString(request.Form("phone"))
fax = dealInputString(request.Form("fax"))
mail = dealInputString(request.Form("mail"))
address = dealInputString(request.Form("address"))
note = dealInputString(request.Form("note"))

licence=trim(request("licence")) '得到用户输入的用户名

set rs=server.createobject("adodb.recordset")
sql="select licence from member where licence='"& licence &"'" '查询数据库中相同的
rs.open conn,1,1
if not (rs.eof and rs.bof) then
response.write "这个用户名已经有人使用了"
response.end
else


dim cn, sql, rs
sql = "insert into tblmqhy (licence,company,trade,town,company_info,licence_date,deputy,workers,money,phone,fax,mail,address,note) values ('" & licence & "','" & company & _
"','" &trade & "','" &town & "','" & company_info & "','" & licence_date & "','" & deputy & "','" & workers & "','" & money & "','" & phone & "','" & fax & "','" & mail & "','" & address & "','" & note & "')"

set cn = server.CreateObject("adodb.connection")
cn.Open getCnStr()
cn.Execute(sql)
cn.Close
set cn = nothing


response.write"<script language=javascript>alert('恭喜!您的申请提交成功!请等待管理员审核...');window.location.href='default.asp';</script>"
'response.Redirect("success.asp") '跳转到簿默认页
end if

%>
...全文
301 19 打赏 收藏 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
hometohome 2006-06-14
  • 打赏
  • 举报
回复
if not conn.execute("select licence from member where licence='"&licence&"'").eof then
response.write ("用户已存在")
end if
qq52668 2006-06-14
  • 打赏
  • 举报
回复
谢谢各位朋友的帮助,我还是没有搞定 仍然出同样的错误。licence这个字段为“varchar”型。用了另一种方法也同样出错。对于朋友们的观注小生再次表示感谢!



稻草人seu 2006-06-14
  • 打赏
  • 举报
回复
直接这样写
set rs1=conn.execute("select licence from member where licence='"&licence &"'")

if not (rs1.EOF and rs1.bof) then
response.write用户名已存在!"
rs1.close
set rs1=nothing
end if
稻草人seu 2006-06-14
  • 打赏
  • 举报
回复
你的rs参数使用多次 没有关闭
qq52668 2006-06-14
  • 打赏
  • 举报
回复
分值太少 只好每人一点。。。
heroooooo 2006-06-13
  • 打赏
  • 举报
回复
你的conn定义了没有,再不就是将rs.open conn,1,1
改成rs.open conn,3,1
qq52668 2006-06-13
  • 打赏
  • 举报
回复
错误类型:
ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/mqhy/add.asp, 第 23 行


第 23 行就是这一块:
----------------------------------------------

set rs=server.createobject("adodb.recordset")
sql="select licence from member where licence='"& licence &"'" '查询数据库中相同的
rs.open conn,1,1
------------------------------------------
heroooooo 2006-06-13
  • 打赏
  • 举报
回复
出现了什么错误??
lolo2006 2006-06-13
  • 打赏
  • 举报
回复
if not (rs.eof and rs.bof) then =====>if not rs.eof or rs.bof then
response.write "这个用户名已经有人使用了"
response.end
else
qq52668 2006-06-13
  • 打赏
  • 举报
回复
在线等。。。自己顶下
qq52668 2006-06-13
  • 打赏
  • 举报
回复
还是出现同样的错误   。。。。郁闷中
wtg321 2006-06-13
  • 打赏
  • 举报
回复
同乐.....
有时会犯点小毛病也是经常的...俺也这样错过.
北京不不 2006-06-13
  • 打赏
  • 举报
回复
呵呵~是有点晕。。rs.open conn,1,1语句都没有。。取数据。。。强啊`~同意楼上。亏了这么多人才看出来。。搞笑~
TaoTaoYou 2006-06-13
  • 打赏
  • 举报
回复
偶晕,,看看你写的什么?rs.open conn,1,1

应该这样写吧:
rs.open Sql,conn,1,1
szlzc 2006-06-13
  • 打赏
  • 举报
回复
if (not rs.eof) and (not rs.bof) then
heroooooo 2006-06-13
  • 打赏
  • 举报
回复
刚才没有看见rs.open conn,1,1,你的这个没有数据库的操作,加上就好了rs.open sql,conn,3,3
lolo2006 2006-06-13
  • 打赏
  • 举报
回复
数据类型不一致
输出licence字段类型看看
qq52668 2006-06-13
  • 打赏
  • 举报
回复
没有解决问题 继续在线等
qq52668 2006-06-13
  • 打赏
  • 举报
回复
如heroooooo()所说改了“改成rs.open conn,3,1” 还是出一样的错误

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧