我有以下代码:
<cfif SideSell neq "">
<cftry>
<cfif listlen(SideSell, ",") gt 0>
<cfset sidesellvalid = true>
<cfelse>
<cfset sidesellvalid = false>
</cfif>
<cfcatch type="any">
<cfset sidesellvalid = false>
</cfcatch>
</cftry>
<cfif sidesellvalid>
<cfset AddPartNumber = "">
<cfset AddDescription = "">
<cfset AddQuantity = "">
<cfset AddPrice = "">
<cfset OptionPrice = "">
<cfset AddItem = "">
<cfloop list="FORM.SideSell" index="SideSellListIndex" delimiters=",">
<cfquery name="qSideSellParts" datasource="Pascal">
SELECT * from Part WHERE PartNumber = <cfqueryparam cfsqltype="cf_sql_varchar" list="yes" separator="," maxlength="45" value="#ListGetAt(SideSell, SideSellListIndex, ',')#">
</cfquery>
<cfset AddPartNumber = "#qSideSellParts.PartNumber#">
<cfset AddDescription = "#qSideSellParts.SubCategory#">
<cfset AddQuantity = "1">
<cfset AddPrice = "#qSideSellParts.PartPrice1#">
<cfset OptionPrice = "0">
<cfset AddItem = "Add To Cart">
<cfinclude template="checkpart.cfm">
</cfloop>
</cfif>
</cfif>
但是,CF 抛出了一个类型转换异常,说
“FORM.SideSell 的值不能转换为数字。”
在 SQL 行:
SELECT * from Part WHERE PartNumber = <cfqueryparam cfsqltype="cf_sql_varchar" list="yes" separator="," maxlength="45" value="#ListGetAt(SideSell, SideSellListIndex, ',')#">
我尝试过的测试数据包括“PTI 19-1”和“PTI 19-1,PTI 19-2”,因此无论列表项数如何,问题都存在。我只是缺少或滥用引号吗?
编辑:在我的测试服务器上运行 CF9,在生产服务器上运行 CF8。我使用<cfdump>
标签来验证数据是否符合我的预期,并且确实如此。