d.n.age合成攻略:ASP里面insert 语句要怎么写啊?

来源:百度文库 编辑:高考问答 时间:2024/05/04 19:17:12
<%
topic=request.form("topic")
sname=request.form("sname")
email=request.form("email")
oicq=request.form("ociq")
homepage=request.form("homepage")
tel=request.form("tel")
content=request.form("content")
other=request.form("other")
exec="insert into bbs(topic,sname,email,oicq,homepage,tel,content,other)values('"+topic+"','"+sname+"','"+email+"',"+oicq+",'"+homepage+"',"+tel+",'"+content+"','"+other+"')"
con.execute exec
con.close
set conn=nothing
response.redirect "bbs_show.asp"
%>
这样写哪出错了?提示是INSERT INTO 语句语法错误。

应该是这样的
exec="insert into bbs(topic,sname,email,oicq,homepage,tel,content,other)values('"&topic&"','"&sname&"','"&email&"',"&oicq&",'"&homepage&"',"&tel&",'"&content&"','"&other&"')"
如果要是数字"&oicq&"要是文本就'"&sname&"'

还有个楼主必须给于关注的是你使用的这个exec,最好换成别的,因为和execute 太接近了
容易出问题,比如换成sql或者什么的都可以啊

exec="insert into bbs(topic,sname,email,oicq,homepage,tel,content,other)values('"&topic&"','"&sname&"','"&email&"',"&oicq&",'"&homepage&"',"&tel&",'"&content&"','"&other&"')"
如果要是数字"&oicq&"要是文本就'"&sname&"'

exec=\"insert into bbs(topic,sname,email,oicq,homepage,tel,content,other) values (\'\"&topic\"\',\'\"&sname\"\',\'\"&email\"\',\"&oicq\",\'\"&homepage\"\',\"&tel\",\'\"&content\"\',\'\"&other\"\')\" 你看看

exec="insert into bbs(topic,sname,email,oicq,homepage,tel,content,other)values('"&topic&"','"&sname&"','"&email&"',"&oicq&",'"&homepage&"',"&tel&",'"&content&"','"&other&"')"

这样试试

你可以在con.execute exec 行的前面加一句
response.wirte exec看看输出结果。

我运行了你的程序,没运行出来错误!
可能是你的IE浏览器版本过低造成的