asp的问题 添加记录

来源:百度知道 编辑:UC知道 时间:2024/05/07 09:49:11
我要实现数据库的增加记录
下面这段代码提示
Microsoft OLE DB Provider for ODBC Drivers (0x80040E0C)
没有为命令对象设置命令。
是怎么回事 ?
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("myimpig.mdb")
name=request.form("name")
email=request.form("email")
qq=request.form("qq")
if request("sort")=2 then
sql="insert into replytechnic(name,email,qq,content)values('"+name+"','"+email+"','"+qq+"')"
end if
if request("sort")=3 then
sql="insert into replyarticle(name,email,qq,content)values('"+name+"','"+email+"','"+qq+"')"
end if
conn.execute sql
conn.close
set conn=nothing
response.write "记录添加成功!"
%>
用了楼下的方法还是不行?

我说你最好把+号,换成&

我曾遇到过过—————&有效,而+没效的时候

你这语句明显有错误么,你sql写了两条,执行的时候怎么知道执行哪一条呢?
应该这样写:

if request("sort")=2 then
sql="insert into replytechnic(name,email,qq,content)values('"+name+"','"+email+"','"+qq+"')"

Elseif request("sort")=3 then
sql="insert into replyarticle(name,email,qq,content)values('"+name+"','"+email+"','"+qq+"')"
end if

conn.execute sql

insert语句前后不匹配:
sql="insert into replytechnic(name,email,qq,content)values('"+name+"','"+email+"','"+qq+"')"
end if
if request("sort")=3 then
sql="insert into replyarticle(name,email,qq,content)values('"+name+"','"+email+"','"+qq+"')"

去掉这2句中的",cont