Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error Message

Participant ,
Nov 18, 2009 Nov 18, 2009

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 ?

TOPICS
Getting started
568
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 18, 2009 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 18, 2009 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2009 Nov 18, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2009 Nov 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)#

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources