<cfset strsql = "select factoryname ,vendorname from tvendor where vendorname = '上海汽车'">
<cfquery name="selecttable44" datasource="#application.sysdsn#">
#strsql#
</cfquery>
debug的地方发现应用服务器吧语句变成:
"select factoryname ,vendorname from tvendor where vendorname = ''上海汽车''"
数据库端就无法解析这个sql语句了。
难道不能动态的构造sql语句。必须写死在<cfquery></cfquery>当中?
------解决方案--------------------------------------------------------
使用presservesinglequotes
<cfset strsql = "select factoryname ,vendorname from tvendor where vendorname = '上海汽车'">
<cfquery name="selecttable44" datasource="#application.sysdsn#">
#presservesinglequotes(strsql)#
</cfquery>