首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

为什么小弟我的数据插入不进数据库啊请高手帮帮忙!

2012-06-20 
为什么我的数据插入不进数据库啊,请高手帮帮忙!!!!在线等!--#include fileconn.asp--%if session(a

为什么我的数据插入不进数据库啊,请高手帮帮忙!!!!在线等
<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录!');history.go(-1);</script>"
response.End
else
if request.cookies("Buy2Buy")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录!');history.go(-1);</script>"
response.End
end if
end if
if session("rank")>2 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权添加修改退伙信息!');history.go(-1);</script>"
response.End
end if

if request.form("name")="" then
conn.close
set conn = nothing
response.Write "<script language=javascript>alert('请填写姓名!');history.go(-1);</script>"
response.End
end if

dim action,id,i,strmeto
id=SafeRequest("id",1)
action=FormatSQL(SafeRequest("action",0))
select case action
case "add"
For i = 1 To Request.Form("meto").Count 
strmeto = strmeto & Request.Form("meto")(i) 
Next 
sql="Insert into tuihuo(danweiid,name,jiari,xiujia,zhuyuan,kaihui,qita,datetime,overtime,heji,jine,meto,adddate) values('"&trim(request.form("danweiid"))&"','"&trim(request.form("name"))&"','"&trim(request.form("jiari"))&"',"&trim(request.form("xiujia"))&","&trim(request.form("zhuyuan"))&","&trim(request.form("kaihui"))&","&trim(request.form("qita"))&","&trim(request.form("datetime"))&","&trim(request.form("overtime"))&","&trim(request.form("heji"))&",'"&trim(request.form("jine"))&"','"&trim(request.form("meto"))&"',"&now&"')"
'response.write sql
'response.end
conn.execute(sql)
response.Write "<script language=javascript>alert('添加成功!');history.go(-1);</script>"
response.End

case "edit"
For i = 1 To Request.Form("meto").Count 
strmeto = strmeto & Request.Form("meto")(i) 
Next 

sql = "Update tuihuo set danweiid='"&trim(request.form("danweiid"))&"',name='"&trim(request.form("name")) &"',jiari='"&trim(request.form("jiari")) &"',xiujia="&trim(request.form("xiujia")) &",zhuyuan="&trim(request.form("zhuyuan")) &",kaihui="&trim(request.form("kaihui")) &",qita="&trim(request.form("qita"))&",datetime="&trim(request.form("datetime")) &",overtime="&trim(request.form("overtime")) &",heji="&trim(request.form("heji")) &",jine='"&trim(request.form("jine")) &"',meto='"&trim(request.form("meto"))&"' where id="&id  
'response.write sql
'response.end
conn.execute(sql)
response.Write "<script language=javascript>alert('修改成功!');history.go(-1);</script>"
response.End
end select
%>
运行后增加的提示是

Insert into tuihuo(danweiid,name,jiari,xiujia,zhuyuan,kaihui,qita,datetime,overtime,heji,jine,meto,adddate) values('2','ffffffff','true',,,,,2011-12-12,2012-01-30,11,'500','ffffffffff',2012-6-14 下午 05:09:35')

修改内容后的提示是


Update tuihuo set danweiid='2',name='sdfgfdg',jiari='',xiujia=True,zhuyuan=,kaihui=,qita=,datetime=2012-5-30,overtime=2012-6-30,heji=222,jine='222',meto='1201' where id=2




[解决办法]
去掉conn.as这个里面的容错语句,看看提示什么错误
[解决办法]
conn.asp里有一行行on err 开头的容错语句。意思是遇到错误继续执行。

[解决办法]
很明显是sql语句错了 出空值的前后加上 ' '
[解决办法]
把传递过来的参数赋值给变量 并对空置设定默认值 int 默认0 文本默认''
[解决办法]
格式不对。
[解决办法]
把代码复制然后在SQL SERVER的查询分析器上执行下就知道哪错了,我看到的是时间格式应该是要用‘号包起来的。
[解决办法]
conn.open()
conn.execute(sql)
...........
.........
..........
conn.execute(sql)
conn.close
你多加一次conn.open看看行不?

热点排行