INSERT INTO 语句的语法错误 30

我用dreamweaver预览后,浏览器提示INSERTINTO语句语法错误,好心人帮帮忙啊我代码<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"... 我用dreamweaver预览后,浏览器提示INSERT INTO 语句语法错误,好心人帮帮忙啊
我代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/db2.asp" -->
<%

set goumai = Server.CreateObject("ADODB.Command")
goumai.ActiveConnection = MM_db2_STRING
goumai.CommandText = "INSERT INTO book(bookid) VALUES("&request.querystring("bookid")&")"
goumai.CommandType = 1
goumai.CommandTimeout = 0
goumai.Prepared = true
goumai.Execute()

%>
说是第11行有错
第11行:goumai.Execute()
展开
 我来答
屈姜以绿
2011-05-19 · TA获得超过255个赞
知道小有建树答主
回答量:601
采纳率:0%
帮助的人:0
展开全部
<%
// *** Insert Record: construct a sql insert statement and execute it

if (String(Request("MM_insert")) != "undefined") {

// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "") + formVal;
}
MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";

if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
response.write MM_editQuery
response.end()
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();

if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}

}
%>
<%
var RecordsetCDB = Server.CreateObject("ADODB.Recordset");
RecordsetCDB.ActiveConnection = MM_ConnCDB_STRING;
RecordsetCDB.Source = "SELECT * FROM [Database]";
RecordsetCDB.CursorType = 0;
RecordsetCDB.CursorLocation = 2;
RecordsetCDB.LockType = 1;
RecordsetCDB.Open();
var RecordsetCDB_numRows = 0;
%>

把这个页面的执行结果贴出来。
追问
不明白
+下我Q373571846详细说下好么?谢谢了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
pkwer
2011-05-19 · TA获得超过127个赞
知道答主
回答量:93
采纳率:0%
帮助的人:87.6万
展开全部
goumai.CommandText = "INSERT INTO book(bookid) VALUES("&request.querystring("bookid")&")"
能确保bookid不为空吗?这句话前面加个判断,不为空再接着跑
追问
怎么加判断?
我bookid项是自动编号,跟这有关么?
追答
你在这句话之前加if(request.querystring("bookid")!=null)
{
goumai.CommandText = "INSERT INTO book(bookid) VALUES("&request.querystring("bookid")&")"
goumai.CommandType = 1
goumai.CommandTimeout = 0
goumai.Prepared = true
goumai.Execute()
}else{//wrong}
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
19732
2011-05-19 · TA获得超过420个赞
知道小有建树答主
回答量:238
采纳率:0%
帮助的人:161万
展开全部
goumai.Execute("INSERT INTO book(bookid) VALUES("&request.querystring("bookid")&")")
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式