你好。我得到一个语法错误在此声明后,我做了一个测试我的形式提交:经典asp数据库插入问题
“Microsoft Jet数据库引擎错误‘80040E14’
查询表达式语法错误(缺少运算符)“c_name ='Golden Wattle'AND sc_name ='Acacia pycnantha'AND url ='http://anpsa.org.au/a-pyc.html'AND image ='http://anpsa.org.au/jpg/029_2.jpg'AND price ='$ 72'AND information ='Golden Wattle is Australia's national floral emblem。'。
/courses/benv/2410/2013s2/3420384/Exercises/ex05/insert-plant.asp,line 54“
对于我的生活,我无法理解这里出了什么问题。
dim cn, sc, url, image, price, desc
cn=Request.Form("new_cn")
sc=Request.Form("new_sc")
url=Request.Form("new_url")
image=Request.Form("new_image")
price=Request.Form("new_price")
desc=Request.Form("new_desc")
'--- check to see whether there already are items of that name...
SQL="select ID from PlantTable where c_name='"& cn & "' AND sc_name='" & sc & "'"&_
" AND url='"&url& "' AND image='"&image& "' AND price='"&price& "' AND information='"&desc& "' "
set info = conn.execute(SQL)
if info.eof then
'--- there is no plant of that name at present, so do the insert
SQL="insert into PlantTable (c_name, sc_name, url, image, price, information) values ('" & cn & "', "&sn&","&url&","&image&","&price&","&desc&")"
conn.execute(SQL)
response.write "Insertion completed."
else
'--- there is already a plant of that name...
response.write "Sorry, that Plant Name is already in the database."
end if
调试101:添加打印语句打印出来的T-SQL语句发送到数据库引擎... –
@MitchWheat谢谢您的帮助。我打印出一条SQL语句发送到数据库引擎并发现一个错误。 sc变量被写为sn。我改变了这一点。然后我收到另一个错误: 'Microsoft JET数据库引擎错误'80040e14' INSERT INTO语句中的语法错误。 /courses/benv/2410/2013s2/3420384/exercises/ex05/insert-plant.asp,line 61' 我试着打印出声明,但至今没有运气找到错误。 – chap
这种问题的典型解决方案:使用[参数化查询](http://stackoverflow.com/a/18619736/1630171)。 –