CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

数据库指针问题

楼主chqsll707()2006-05-04 08:42:40 在 Web 开发 / ASP 提问

做了个注册页面,注册成功后把注册内容也写入数据库表中了,但如果再注册的话,后一次注册的内容在数据库的表中把前一次的内容覆盖掉了,我想应该是指针没有写对吧,更新后没有下移,但不知道怎么改,望帮忙.源程序如下:  
  <%   @language="vbscript"   %>  
  <!--#include   file="conn.asp"-->  
  <%  
  Function   ListError(marray)  
  f_marray=split(marray,"|",-1,1)  
  for   i=0   to   ubound(f_marray)-1  
  Str=str&(i+1)&"、"&f_marray(i)&"<br>"  
  next  
  ListError=Str  
  end   Function  
   
  userid=request("userid")  
  password=request("password")  
  name=request("name")  
  email=request("email")  
   
  if   request("register")<>""   then  
  a_str="qwertyuiopasdfghjklzxcvbnmQWERYTUIOPASDFGHJKLZXCVBNM1234567890_"  
  err_str=""  
   
  if   userid<>""   then  
  for   i=1   to   len(userid)  
  if   instr(a_str,mid(userid,i,1))=0   then  
  err_str=err_str&"登录账号的输入值出错|"  
  exit   for  
  end   if  
  next    
  end   if  
   
  if   password=""   then   err_str=err_str&"密码不能为空值|"  
  if   password<>request("cnpwd")   then   err_str=err_str&"密码与确认密码不同,请重新输入|"  
  if   name=""   then   err_str=err_str&"真实姓名不能为空值|"  
  if   email=""   then   err_str=err_str&"email不能为空值|"  
  if   instr(email,"@")=0   or   instr(email,"@")=1   or   instr(email,"@")=len(email)   then  
  err_str=err_str&"email出错|"  
  elseif   instr(email,".")=0   or   instr(email,".")=1   or   instr(email,".")=len(email)   or   instr(email,".")<instr(email,"@")   then  
  err_str=err_str&"email出错|"  
  end   if  
   
  Set   rs   =   Server.CreateObject("ADODB.Recordset")    
    rs.ActiveConnection   =   conn  
  'set   rs=Server.CreateObject("ADODB.connection")  
  rs.open   "SELECT   *   FROM   member",conn,3,2  
   
  b_str="register|cnpwd|submit2"  
  if   err_str=err_str&""   then  
  for   each   keystr   in   request.form  
  if   instr(b_str,keystr)=0   and   request(keystr)<>""   then  
  rs.fields(keystr)=request(keystr)  
  end   if  
  next    
  rs.update  
  rs.movenext  
  end   if  
  rs.close  
  response.redirect   "index.html"  
  end   if  
  %>  
  <html>  
  <head>  
  <title>注册</title>  
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">  
  <link   rel="stylesheet"   href="friend.css"   type="text/css">  
   
  </head>  
  <body   bgcolor="#FFFFFF"   text="#000000">  
  <table   width="770"   border="0"   cellspacing="0"   cellpadding="0"   class="font10">  
  <tr>  
  <td><b><font   color="#6666FF">个人资料注册</font></b>  
  <%  
  '如果注册信息中有错误就显示出错误  
  if   err_str<>""   then  
  %>  
  <div   id="Layer1"   style="position:absolute;   width:182px;   height:189px;   z-index:1;   left:10px;   top:44px"><font   color="#FF0000"><b>错误:   <br>  
  </b><%=ListError(err_str)%></font>  
  <%  
  end   if  
  %>  
  </div>  
  </td>  
  </tr>  
  <tr>  
  <td   bgcolor="#336699"></td>  
  </tr>  
  <tr>  
  <td><br>  
  <table   width="500"   border="0"   align="center"   cellspacing="0"   cellpadding="0"   class="font10">  
  <form   name="form1"   method="post"   action="">  
  <tr>  
  <td   width="118"   align="right"><font   color="<%   if   instr(h_error,",1,")<>0   then   response.write   "#FF0000"%>">登录账号:   </font></td>  
  <td   width="382">  
  <input   type="text"   name="userid"   size="20"   maxlength="10"  
  value="<%=userid%>">  
  <font   color="#FF0000">*</font></td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right"><font   color="<%   if   instr(h_error,",2,")<>0   then   response.write   "#FF0000"%>">密码:   </font></td>  
  <td   width="382">  
  <input   type="password"   name="password"   size="20"   maxlength="10"  
  value="<%=password%>">  
  <font   color="#FF0000">*</font></td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right"><font   color="<%   if   instr(h_error,",2,")<>0   then   response.write   "#FF0000"%>">确定密码:   </font></td>  
  <td   width="382">  
  <input   type="text"   name="cnpwd"   size="20"   maxlength="10"  
  value="<%=cnpwd%>">  
  <font   color="#FF0000">*</font></td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right">性别:   </td>  
  <td   width="382">  
  <input   type="radio"   name="gender"   value="1"   checked>  
  男  
  <input   type="radio"   name="gender"   value="0"   <%   if   gender="0"   then   response.write   "checked"%>>  
  女</td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right"><font   color="<%   if   instr(h_error,",5,")<>0   then   response.write   "#FF0000"%>">电子邮件:   </font></td>  
  <td   width="382">  
  <input   type="text"   name="email"   size="50"    
  value="<%=email%>">  
  <font   color="#FF0000">*</font></td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right"><font   color="<%   if   instr(h_error,",3,")<>0   then   response.write   "#FF0000"%>">真实姓名:   </font></td>  
  <td   width="382">  
  <input   type="text"   name="name"   size="20"   maxlength="10"  
  value="<%=name%>">  
  <font   color="#FF0000">*</font></td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right">身份证号:   </td>  
  <td   width="382">  
  <input   type="text"   name="idcard"   size="50"  
  value="<%=idcard%>">  
  </td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right"><font   color="<%   if   instr(h_error,",5,")<>0   then   response.write   "#FF0000"%>">密码问题:   </font></td>  
  <td   width="382">  
  <input   type="text"   name="question"   size="50"    
  value="<%=question%>">  
  </td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right"><font   color="<%   if   instr(h_error,",5,")<>0   then   response.write   "#FF0000"%>">密码答案:   </font></td>  
  <td   width="382">  
  <input   type="text"   name="answer"   size="50"    
  value="<%=answer%>">  
  </td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right">所在省份:   </td>  
  <td   width="382">  
  <select   name="province">  
  <option   value=1>北京</option>  
  <option   value=2>上海</option>  
  <option   value=3>天津</option>  
  <option   value=4>重庆</option>  
  <option   value=5>广东</option>  
  <option   value=6>浙江</option>  
  <option   value=7>湖南</option>  
  <option   value=8>江西</option>  
  <option   value=9>四川</option>  
  <option   value=10>山东</option>  
  <option   value=11>辽宁</option>  
  <option   value=12>湖北</option>  
  <option   value=13>山西</option>  
  <option   value=14>陕西</option>  
  <option   value=15>广西</option>  
  </select>  
  </td>  
  </tr>  
  <tr>  
  <td   width="118"   align="right">主页:</td>  
  <td   width="382">  
  <input   type="text"   name="homepage"   size="50"   value="<%=homepage%>">  
  </td>  
  </tr>  
  <tr>  
      <td   colspan="2">  
          <div   align="center">  
              <input   type="submit"   name="register"   value="确定提交">  
              &nbsp;&nbsp;&nbsp;&nbsp;      
              <input   type="reset"   name="submit"   value="重新再填">  
              </div></td>  
  </tr>  
  <tr>  
  <td   width="118">&nbsp;</td>  
  <td   width="382">&nbsp;</td>  
  </tr>  
  </form>  
  </table>  
  </td>  
  </tr>  
  </table>  
  </body>  
  </html> 问题点数:30、回复次数:6Top

1 楼moodboy1982(老鹰)回复于 2006-05-04 09:35:46 得分 0

后一次的不会复盖前面的呀。只能再添加一次呀。  
  只有用update更新才是“复盖”  
   
   
   
   
   
   
  ----------个性签名---------------  
  http://www.esoftnow.com/bbs  
  技术论坛,欢迎光监,发贴  
   
   
   
   
  Top

2 楼coolattt(隐锋)回复于 2006-05-04 10:27:34 得分 0

在  
  if   instr(b_str,keystr)=0   and   request(keystr)<>""   then  
  后面加一句:  
  Rs.AddNew  
  Top

3 楼heroooooo(学习.NET)回复于 2006-05-04 12:02:20 得分 0

在  
  if   instr(b_str,keystr)=0   and   request(keystr)<>""   then  
  后面加:  
  rs.movenext  
  rs.addnew  
  不加   rs.movenext时,所添加的记录都会在第一个位置..对了,记得将你的数据库打开方式做成可写的。。  
  ps:上一个你的贴子错误的原因是什么??  
  Top

4 楼chqsll707()回复于 2006-05-04 12:59:01 得分 0

数据是写进去了,不过不在同一个记录内,好像一条记录一个内容,就像姓名在一个记录,密码就跑到下一个记录了,上一帖子的问题是因为失误,写错了一个字母Top

5 楼heroooooo(学习.NET)回复于 2006-05-04 13:41:43 得分 0

上一帖子的问题是因为失误,写错了一个字母  
  -----------------------------------------------  
  看来以后问问题先看看自己有没有问对.呵呵..  
   
  看了你的程序,应该是不可能的,当然当你提交的表单很特殊的时候,可能会出现你说的情况..  
  注意这一句:  
  for   each   keystr   in   request.form  
  if   instr(b_str,keystr)=0   and   request(keystr)<>""   then  
  rs.fields(keystr)=request(keystr)  
  end   if  
  next    
   
  好好看看,看不懂的地方就先看看书..Top

6 楼chqsll707()回复于 2006-05-04 13:43:46 得分 0

嗯,谢谢Top

相关问题

关键词

得分解答快速导航

  • 帖主:chqsll707

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo