asp 无法添加新记录到表
现在遇到个很纠结的问题....网页是asp做的,数据库是SQL200的。我用网页程序添加新记录,没法添加进去。但是我在查询分析器里添加记录能添加。但是怪事来了...我的i...
现在遇到个很纠结的问题....网页是asp做的,数据库是SQL200的。我用网页程序添加新记录,没法添加进去。但是我在查询分析器里添加记录能添加。但是怪事来了...我的id字段是主键,自动增长的。我用网页添加记录的时候数据库里始终没有新记录入库。但是ID的值却在增长,直到我用查询分析器添加后,发现原本ID=9,添加后ID=20了;如下图(序号即为ID字段):
请大家帮我分析下原因以下是我的代码,我已经确定,我能收到传来的参数,所以不存在参数为空的情况。
代码:
<%
dim country2,state2,name_tg,zhanghao_tg,szyuid,name_fu,LeiBie,PingPai,YuanJia,TuanGouJia,ZheKou,JieSheng,RenShu,DianHua,DiZhi,JieShao,SuoTu,JieZhiShiJian,KaiShi,JieSu,DiTu,DiTuLianJie,content
sqlstr="select * from tuangou"
set rs=server.createobject("adodb.recordset")
rs.Open sqlstr,conn,1,3
country2= request("country2")
state2= request("state2")
name_tg= request("name_tg")
zhanghao_tg="ww"
szyuid= "001"
name_fu= request("name_fu")
LeiBie= request("LeiBie")
PingPai= request("PingPai")
YuanJia= request("YuanJia")
TuanGouJia= request("TuanGouJia")
ZheKou= request("ZheKou")
JieSheng= request("JieSheng")
RenShu= request("RenShu")
DianHua= request("DianHua")
DiZhi= request("DiZhi")
JieShao= request("JieShao")
SuoTu= request("SuoTu")
JieZhiShiJian= request("JieZhiShiJian")
KaiShi= request("KaiShi")
JieShu= request("JieShu")
DiTu= request("DiTu")
DiTuLianJie= request("DiTuLianJie")
content= request("content")
add_time= now()
city_pass ="F"
ZongJian_pass="F"
rs.addnew
rs("country2") = country2
rs("state2") = state2
rs("name_tg") = name_tg
rs("zhanghao_tg") = "001"
rs("szyuid")="001"
rs("name_fu") = name_fu
rs("leibie") = LeiBie
rs("pingpai") = PingPai
rs("yuanjia") = YuanJia
rs("tuangoujia") = TuanGouJia
rs("zhekou") = ZheKou
rs("jiesheng") = JieSheng
rs("renshu") = RenShu
rs("dianhua") = DianHua
rs("dizhi") = DiZhi
rs("jieshao") = JieShao
rs("suotu") = SuoTu
rs("jiezhishijian") = JieZhiShiJian
rs("kaishi") = KaiShi
rs("jieshu") = JieShu
rs("ditu") = DiTu
rs("ditulianjie") = DiTuLianJie
rs("content") = content
rs("add_time") = now()
rs("city_pass") ="F"
rs("ZongJian_pass") ="F"
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('添加成功!');window.location.href='user_admin_tg.asp';</script>"
%> 展开
请大家帮我分析下原因以下是我的代码,我已经确定,我能收到传来的参数,所以不存在参数为空的情况。
代码:
<%
dim country2,state2,name_tg,zhanghao_tg,szyuid,name_fu,LeiBie,PingPai,YuanJia,TuanGouJia,ZheKou,JieSheng,RenShu,DianHua,DiZhi,JieShao,SuoTu,JieZhiShiJian,KaiShi,JieSu,DiTu,DiTuLianJie,content
sqlstr="select * from tuangou"
set rs=server.createobject("adodb.recordset")
rs.Open sqlstr,conn,1,3
country2= request("country2")
state2= request("state2")
name_tg= request("name_tg")
zhanghao_tg="ww"
szyuid= "001"
name_fu= request("name_fu")
LeiBie= request("LeiBie")
PingPai= request("PingPai")
YuanJia= request("YuanJia")
TuanGouJia= request("TuanGouJia")
ZheKou= request("ZheKou")
JieSheng= request("JieSheng")
RenShu= request("RenShu")
DianHua= request("DianHua")
DiZhi= request("DiZhi")
JieShao= request("JieShao")
SuoTu= request("SuoTu")
JieZhiShiJian= request("JieZhiShiJian")
KaiShi= request("KaiShi")
JieShu= request("JieShu")
DiTu= request("DiTu")
DiTuLianJie= request("DiTuLianJie")
content= request("content")
add_time= now()
city_pass ="F"
ZongJian_pass="F"
rs.addnew
rs("country2") = country2
rs("state2") = state2
rs("name_tg") = name_tg
rs("zhanghao_tg") = "001"
rs("szyuid")="001"
rs("name_fu") = name_fu
rs("leibie") = LeiBie
rs("pingpai") = PingPai
rs("yuanjia") = YuanJia
rs("tuangoujia") = TuanGouJia
rs("zhekou") = ZheKou
rs("jiesheng") = JieSheng
rs("renshu") = RenShu
rs("dianhua") = DianHua
rs("dizhi") = DiZhi
rs("jieshao") = JieShao
rs("suotu") = SuoTu
rs("jiezhishijian") = JieZhiShiJian
rs("kaishi") = KaiShi
rs("jieshu") = JieShu
rs("ditu") = DiTu
rs("ditulianjie") = DiTuLianJie
rs("content") = content
rs("add_time") = now()
rs("city_pass") ="F"
rs("ZongJian_pass") ="F"
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('添加成功!');window.location.href='user_admin_tg.asp';</script>"
%> 展开
3个回答
展开全部
数据类型有问题,你把数据类型仔细调整,你上面全部都是做用的字符型 ,你看看你的数据库里面,是不是也是全部使用的字符型,如果不是,你全部改成字符型,那个日期字段一定要用日期的数据类型 ,检查一下数据库的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看见某些字段似乎是数字类型的,楼主也用引号括起来了,是否因这引起问题。另外可以先把request值屏蔽掉,直接用手写值替代进行测试,就可以知道是哪个字段导致了这个问题。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把字符串打出来看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询