| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 545 人关注过本帖
标题:[求助]请问我这样做是不是不对的啊?
只看楼主 加入收藏
zmyzzz
Rank: 1
等 级:新手上路
帖 子:145
专家分:0
注 册:2005-9-21
收藏
 问题点数:0 回复次数:5 
[求助]请问我这样做是不是不对的啊?

这个是acc.asp中的内容: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <% option explicit dim conn,db,sql,username,userphone db="mdb/aaaa.mdb" Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) sql="select *from aaaaa" Set rs = Server.CreateObject("ADODB.RecordSet") username=request.form("username") userphone=request.form("userphone") if username<>"" and userphone<>"" then do while not rs.eof if username=rs.("name") response.write "该用户已经存在" else rs.movenext loop end if else sql="insert into aaaaa (name,phone) values ('"&username&"','"&userphone&"')" conn.Execute(sql) response.write "用户:"&username&"添加成功!" end if conn.close set conn=nothing %> 这个是 测试插入数据.htm中的内容: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>测试插入数据</title> <style type="text/css"> <!-- .style1 { font-family: "宋体"; font-size: 10pt; } --> </style> </head>

<body> <table width="412" cellspacing="0" cellpadding="0"> <tr> <td width="410"><form name="form1" method="post" action="acc.asp"> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="44%"><span class="style1">用户名:</span> <input name="textname" type="text" id="textname" size="15"></td> <td width="56%"><span class="style1">电话:</span> <input name="textphone" type="text" id="textphone" size="15"> <input type="submit" name="Submit" value="提交"></td> </tr> </table> </form></td> </tr> </table> </body> </html> 我想在点击“提交“后进行验证,如果用户名有重复的,就提示错误,如果没有,就插入数据,这么做可以么??我怎么点完"提交"之后没有反应呢? 能帮我看看么....谢谢!!!

搜索更多相关主题的帖子: blank option target aaaaa 
2005-09-22 08:42
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
Set rs = Server.CreateObject("ADODB.RecordSet") username=request.form("username") userphone=request.form("userphone") if username<>"" and userphone<>"" then sql="select *from aaaaa where name=username" if not rs.eof then response.write "该用户已经存在" else sql="insert into aaaaa (name,phone) values ('"&username&"','"&userphone&"')" conn.Execute(sql) response.write "用户:"&username&"添加成功!" end if end if conn.close set conn=nothing %>
2005-09-22 08:53
zmyzzz
Rank: 1
等 级:新手上路
帖 子:145
专家分:0
注 册:2005-9-21
收藏
得分:0 
哦.....棒锤了......谢谢你......真笨阿我

吾尝终日而思之,不如须臾之所学也
2005-09-22 11:47
zmyzzz
Rank: 1
等 级:新手上路
帖 子:145
专家分:0
注 册:2005-9-21
收藏
得分:0 
我按你说的改了,但是他提示我对象关闭时不允许操作,麻烦你再帮我看看好么...谢谢!! <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <% option explicit dim conn,db,sql,username,userphone dim rs db="mdb/aaaa.mdb" Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) sql="select *from aaaaa" Set rs = Server.CreateObject("ADODB.RecordSet") username=request.form("textname") userphone=request.form("textphone") sql="select * from aaaaa where name=username" if not rs.eof then response.write "该用户已经存在" else sql="insert into aaaaa (name,phone) values ('"&username&"','"&userphone&"')" conn.Execute(sql) response.write "用户:"&username&"添加成功!" end if rs.close conn.close set conn=nothing %>

吾尝终日而思之,不如须臾之所学也
2005-09-22 12:06
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
if username<>"" and userphone<>"" then sql="select *from aaaaa where name=username" rs.open sql,conn,1,1 if not rs.eof then response.write "该用户已经存在" else
2005-09-22 12:13
zmyzzz
Rank: 1
等 级:新手上路
帖 子:145
专家分:0
注 册:2005-9-21
收藏
得分:0 
已经ok了,谢谢!!!
还有哦.....版主能否将QQ告诉偶呢....
偶是新新手....有很多很多问题要问你呢

吾尝终日而思之,不如须臾之所学也
2005-09-22 17:09
快速回复:[求助]请问我这样做是不是不对的啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018804 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved