Skip to main content
Inspiring
November 18, 2009
Question

Error Message

  • November 18, 2009
  • 3 replies
  • 563 views

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 ?

This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
November 18, 2009

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)#

trojnfnAuthor
Inspiring
November 18, 2009

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.

BKBK
Community Expert
Community Expert
November 18, 2009

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]#'

Inspiring
November 18, 2009

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.