Copy link to clipboard
Copied
I am getting this error message when I attempt to update :
Error converting data type varchar to float.
It is telling me that I am trying to put an alphanumeric field into a numeric decimal field ?
Here is the code I am using for my update :
update gfmPartNumbers
set conditionCode = '#Evaluate("form.conditionCode#gfmPartNumberID#")#',
materialNumber = '#Evaluate("form.materialNumber#gfmPartNumberID#")#',
quantity = '#Evaluate("form.quantity#gfmPartNumberID#")#',
unitValue = '#Evaluate("form.unitValue#gfmPartNumberID#")#'
The conditionCode is datatype nvarchar lenght 20, the materialNumber is nvarchar length 50, the quantity is int length 4 and the unitValue is decimal length 9.
I checked all the values on the screen before submitting and they all look good. The error message does not pinpoint me anywhere, what else and where else can I look ?
Copy link to clipboard
Copied
Your specific error is caused by the single quotes around the evaluate function.
Evaluate is not the most effective way to do this. Array notation, ie form["static part" & variable part] accomplishes the same thing more efficiently. Also, <cfqueryparam> does a lot of good things for you.
Copy link to clipboard
Copied
are you saying to remove the single quotes and just have this ?
set conditionCode = #Evaluate("form.conditionCode#gfmPartNumberID#")#'
materialNumber = #Evaluate("form.materialNumber#gfmPartNumberID#")#
quantity = #Evaluate("form.quantity#gfmPartNumberID#")#,
unitValue = #Evaluate("form.unitValue#gfmPartNumberID#")#
This is inside a cfquery, so will that work ? I guess I will run and see.
Copy link to clipboard
Copied
are you saying to remove the single quotes and just have this ?
set conditionCode = #Evaluate("form.conditionCode#gfmPartNumberID#")#'
<cfset unitVal = "unitValue" & gfmPartNumberID>
and then, in the query,
set unitValue = '#form[unitVal]#'
Copy link to clipboard
Copied
Did you turn debugging on? When Coldfusion shows you a database error, it also returns a copy of the query. Look in there and you will certainly find the clue.
UnitValue is numeric. There should therefore be no quotes around its value.
Dan's seems to me the better way to write it. But if you insist on using the evaluate() function, rewriting it as follows would be easier on the eyes:
<cfset gfmPartNumberID = "form.conditionCode" & gfmPartNumberID>
<cfset materialNumber = "form.materialNumber" & gfmPartNumberID>
<cfset quantity = "form.quantity" & gfmPartNumberID>
<cfset unitValue = "form.unitValue" & gfmPartNumberID>
set conditionCode = '#Evaluate(gfmPartNumberID)#',
materialNumber = '#Evaluate(materialNumber)#',
quantity = '#Evaluate(quantity)#',
unitValue = #Evaluate(unitValue)#
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more