哪位能帮我看看,这段代码错在哪里?

来源:百度知道 编辑:UC知道 时间:2024/06/18 00:11:10
我用dw做的购物车页面,这是一个插入命令,但测试时,总提示insert into语法错误.
<%

set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = "INSERT INTO tOrderDetail (fProductID) VALUES (" + Replace(Command1__strProductID, "'", "''") + ") "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()

%>
我按你教的做了,输出的sql语句是:
INSERT INTO tOrderDetail (fProductID) VALUES ()
下面怎么办啊,先谢谢你啊.

Command1.CommandText = "INSERT INTO tOrderDetail (fProductID) VALUES (" + Replace(Command1__strProductID, "'", "''") + ") "

这一句改成

Command1.CommandText = "INSERT INTO tOrderDetail (fProductID) VALUES ('" + Replace(Command1__strProductID, "'", "''") + "') "

set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = "INSERT INTO tOrderDetail (fProductID) VALUES (" + Replace(Command1__strProductID, "'", "''") + ") "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
response.write Command1.CommandText
response.end
Command1.Execute()

看一下输出的sql语句是什么,然后去调整。