CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

为什么一定要把所有的项填满数据库才能添加

楼主rryqsh(日日野晴矢)2006-02-14 14:13:45 在 Web 开发 / ASP 提问

现在的问题很奇怪,很简单的一个页面,通过得到几个输入框内的字符,然后在数据库中添加一项  
  现在的问题是:一定要把数据库所有的项都填满,它才能添加,否则就完全没有反应,请问这是为什么?  
   
  <!--#include   file="bsconfig.asp"-->  
  <%if   Request.QueryString("no")="eshop"   then%>  
  <%  
  area=server.htmlencode(Trim(Request("area")))  
  place=server.htmlencode(Trim(Request("place")))  
  name1=server.htmlencode(Trim(Request("name")))  
  add=server.htmlencode(Trim(Request("add")))  
  tel=server.htmlencode(Trim(Request("tel")))  
  fax=server.htmlencode(Trim(Request("fax")))  
  pcode=server.htmlencode(Trim(Request("pcode")))  
  email=server.htmlencode(Trim(Request("email")))  
  contractor=server.htmlencode(Trim(Request("contractor")))  
  %>  
  <%  
  If   name1=""   Then  
  response.write   "SORRY   <br>"  
  response.write   "名称不能为空!!<a   href=""javascript:history.go(-1)"">返回重输</a>"  
  response.end  
  end   if  
  If   place=""   Then  
  response.write   "SORRY   <br>"  
  response.write   "所在城市不能为空!!<a   href=""javascript:history.go(-1)"">返回重输</a>"  
  response.end  
  end   if  
  If   add=""   Then  
  response.write   "SORRY   <br>"  
  response.write   "地址不能为空!!<a   href=""javascript:history.go(-1)"">返回重输</a>"  
  response.end  
  end   if  
   
  Set   rs   =   Server.CreateObject("ADODB.Recordset")  
  sql="select   *   from   "+   area  
  rs.open   sql,conn,3,3  
  rs.addnew  
  rs("name")=name1  
  rs("place")=place  
  rs("add")=add  
  rs("tel")=tel  
  rs("fax")=fax  
  rs("pcode")=pcode  
  rs("email")=email  
  rs("contractor")=contractor  
  rs.update  
  rs.close  
  response.redirect   "Bs_sale.asp"  
  end   if  
  %>  
  <!--   #include   file="Inc/Head.asp"   -->  
  <BR>  
  <table   cellpadding="2"   cellspacing="1"   border="0"   width="560"   align="center"   class="a2">  
  <tr>  
  <td   class="a1"   height="25"   align="center"><strong>添加办事处</strong></td>  
  </tr>  
  <tr   class="a4">  
  <td   align="center">  
              <br>  
              <table   width="550"   border="0"   cellspacing="0"   cellpadding="0">  
                  <tr>    
  <form   method="post"   action="Bs_sale_Add.asp?no=eshop"><td><div   align="center">    
  <table   width="100%"   border="0"   cellspacing="2"   cellpadding="3">  
  <tr>    
  <td   width="19%"   height="25"   bgcolor="#C0C0C0">   <div   align="center">选择区域</div></td>  
  <td   width="81%"   bgcolor="#E3E3E3">  
  <select   name="area">  
  <option   value="sell_NE">东北</option>  
  <option   value="sell_N">华北</option>  
  <option   value="sell_E">华东</option>  
  <option   value="sell_S">华南</option>  
  <option   value="sell_M">华中</option>  
  <option   value="sell_NW">西北</option>  
  <option   value="sell_SW">西南</option>  
  </select></td>  
  </tr>  
  <tr>    
  <td   width="19%"   height="25"   bgcolor="#C0C0C0">   <div   align="center">名称</div></td>  
  <td   width="81%"   bgcolor="#E3E3E3">  
  <input   name="name"   type="text"   size="30"   maxlength="50"></td>  
  </tr>  
  <tr>    
  <td   height="22"   bgcolor="#C0C0C0">      
  <div   align="center">所在城市</div></td>  
  <td   bgcolor="#E3E3E3"><input   name="place"   type="text"   size="30"   maxlength="50">  
  </td>  
  </tr>  
  <tr>    
  <td   height="22"   bgcolor="#C0C0C0">   <div   align="center">地址</div></td>  
  <td   height="-4"   bgcolor="#E3E3E3">  
  <input   name="add"   type="text"   size="30"   maxlength="50">    
  </td>  
  </tr>  
  <tr>    
  <td   height="22"   bgcolor="#C0C0C0"><div   align="center">电话</div></td>  
  <td   height="-1"   bgcolor="#E3E3E3">  
  <input   name="tel"   type="text"   size="30"   maxlength="50"></td>  
  </tr>  
  <tr>    
  <td   height="22"   bgcolor="#C0C0C0"><div   align="center">传真</div></td>  
  <td   height="-1"   bgcolor="#E3E3E3">  
  <input   name="fax"   type="text"   size="30"   maxlength="50"></td>  
  </tr>  
  <tr>    
  <td   height="22"   bgcolor="#C0C0C0"><div   align="center">email</div></td>  
  <td   height="-1"   bgcolor="#E3E3E3">  
  <input   name="email"   type="text"   size="30"   maxlength="50"></td>  
  </tr>  
  <tr>    
  <td   height="22"   bgcolor="#C0C0C0"><div   align="center">邮政编码</div></td>  
  <td   height="-1"   bgcolor="#E3E3E3">  
  <input   name="pcode"   type="text"   size="30"   maxlength="50"></td>  
  </tr>  
  <tr>    
  <td   height="22"   bgcolor="#C0C0C0"><div   align="center">联系人</div></td>  
  <td   height="-1"   bgcolor="#E3E3E3">  
  <input   name="contractor"   type="text"   size="30"   maxlength="50"></td>  
  </tr>  
  <tr>    
  <td   height="25"   colspan="2"   bgcolor="#E3E3E3">   <div   align="center">    
  <input   type="submit"   value="确定">  
  &nbsp;    
  <input   type="reset"   value="取消">  
  </div></td>  
  </tr>  
  </table>  
  </div></td></form>  
                  </tr>  
              </table>  
              <br>  
  </td>  
  </tr>  
  </table>  
  <BR>  
   
   
  <%htmlend%>  
  问题点数:20、回复次数:4Top

1 楼samson_www(天天向上)回复于 2006-02-14 14:18:42 得分 8

用response.end跟踪一下,估计是你的数据库中字段设计是要求不能为空Top

2 楼xhbmj(《升龙道》)回复于 2006-02-14 14:35:23 得分 6

你用的是access吧,access默认不能为空,需要手工设置必添字段和允许空字符Top

3 楼tokilcoom(痴迷白骨)回复于 2006-02-14 14:40:55 得分 6

数据属性设置成允许为空Top

4 楼rryqsh(日日野晴矢)回复于 2006-02-14 14:56:11 得分 0

果然一针见血!  
  分数双手奉上,谢谢指教Top

相关问题

  • 数据库添加
  • 添加数据库
  • 数据库操作!——添加!
  • 请问怎样才能把一个数据库的内容添加到另外一个数据库里啊?由click事件来触发
  • 当向数据库添加数据时,怎么才能让DATAGRID实时显示数据更新
  • 不用数据库的情况下,如何才能将添加进去的元素保存下来
  • 添加数据库记录的问题
  • ODBC 数据库编程 --- 添加记录
  • 数据库添加记录问题。
  • 对数据库数据添加问题

关键词

  • 数据库
  • 字段
  • 添加
  • 填满
  • 所有的项
  • 设置
  • 现在的问题
  • 不能为空

得分解答快速导航

  • 帖主:rryqsh
  • samson_www
  • xhbmj
  • tokilcoom

相关链接

  • Web开发类图书

广告也精彩

反馈

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