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() 展开
我代码
<%@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() 展开
3个回答
展开全部
<%
// *** 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;
%>
把这个页面的执行结果贴出来。
// *** 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详细说下好么?谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
goumai.CommandText = "INSERT INTO book(bookid) VALUES("&request.querystring("bookid")&")"
能确保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}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
goumai.Execute("INSERT INTO book(bookid) VALUES("&request.querystring("bookid")&")")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询