| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 433 人关注过本帖
标题:[求助]应该是数据库问题(菜鸟问题)
只看楼主 加入收藏
xiaoxippzyh
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-8-7
收藏
 问题点数:0 回复次数:2 
[求助]应该是数据库问题(菜鸟问题)

出现一个问题,能帮我解决一下么?这个是数据库的设置问题,还是代码写错了
Microsoft OLE DB Provider for SQL Server (0x80040E2F)
无法将 NULL 值插入列 'u_id',表 'text4.dbo.user';该列不允许空值。INSERT 失败。
/xiaoxippzyh/text4/add_save.asp, 第 25 行

代码是<!--#include file="include/config.asp"-->
<!--#include file="include/conn.asp"-->

<% dim str
str=""
if request("name")="" then
str=str & "请输入姓名 <br>" '不加response.write怎么输出丫?

end if
if not isnumeric(request("age")) then
str=str &"请填写年龄 <br>"
end if
dim strsql,thisdate
thisdate=request("year")&"-"&request("month")&"-"&request("day")
dim rs
StrSql="select * from [user] order by u_id desc"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open StrSql,conn,3,3
rs.addnew
rs("u_name")=trim(request("name"))
rs("u_sex")=trim(request("sex"))
rs("u_age")=trim(request("age"))
rs("u_date")=thisdate
rs("u_jianjie")=trim(request("jianjie"))
rs.update
str="保存成功"
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<table width="332" height="82" border="1" align="center">
<tr>
<td bgcolor="#FFFFE6"><%=str%></td>
</tr>
</table>
</body>
</html>
<!--#include file="include/connclose.asp"-->




有人说这是数据库设置问题
字段你设置的不能为空 而你插入的时候该字段是空值
把字段设置为可以为空 或者在页面作不能为空的验证
具体在数据库里怎么操作?
id为主键肯定不能为空的,其他的都可以丫,

搜索更多相关主题的帖子: 数据库 
2007-08-10 00:34
ouyangfeixue
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2007-8-6
收藏
得分:0 
把这个 rs.open StrSql,conn,3,3换成 rs.open StrSql,conn,1,3,还有,你用的是什么数据库.如果是SQL SERVER是可以插入的.前提是这个字段可以为空.如果是ACCESS的,你想插入的话,就要这样:insert into table values('NULL')不明白的地方请联系我,QQ:308046190.我的QQ群:31758718
2007-08-10 08:44
xiaoxippzyh
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-8-7
收藏
得分:0 

谢谢,
我搞定了


2007-08-14 23:55
快速回复:[求助]应该是数据库问题(菜鸟问题)
数据加载中...
 
   



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

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