为什么一定要把所有的项填满数据库才能添加
现在的问题很奇怪,很简单的一个页面,通过得到几个输入框内的字符,然后在数据库中添加一项
现在的问题是:一定要把数据库所有的项都填满,它才能添加,否则就完全没有反应,请问这是为什么?
<!--#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="确定">
<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




