Bad Error Message

May 23, 2005
coldfusion

I recently did this:

<cfoutput query="#queryName#"> ... </cfoutput>

Can you spot the error?

I think that is probably a very common mistake - here's the error message you get in ColdFusion MX 6.1:

Complex object types cannot be converted to simple values. The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values. The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a CFIF tag. This was possible in ColdFusion 2.0 but creates an error in later versions. The error occurred on line 14.

I realize that this is a generic error message, but in this case - for what is probably a very common thing to do - why not something like You passed in a query object, when we expected the name of a query. You may need to remove the pound signs..



You might also like:

This entry was:

Comments

Or here is a crazy idea... instead of throwing an error - just work with the passed in query. ;)
Yeah Ray I thought about that too, but that would create code that didn't work on previous versions of CF... not sure if that is an issue for many people?
Well, the same could be said for cfdocument. It won't work in CF5 either. ;)
Yes I understand that, but if your writing software that has to work on multiple versions of CF it can make it easy to introduce bugs. Again, I'm not sure if that is an issue for many people.
Hi, Iam talking with w.r.t coldfusion MX. If ur getting an error "ByteArray Object cannot be converted to String" Follow this procedure. Here #id# is a ByteArray Object <cfset aAbcArray = ArrayNew(1)> <cfset aAbcArray[1] = #id#> <cfset ArrayAppend(aAbcArray, "")> <cfset one = aAbcArray> <cfset one = #BinaryEncode(#id#,'Hex')#> <cfoutput>#one<cfoutput> Remember ByteArray Object is a complex data type and cannot be converted to simple data type. If u find this problem then use the array value directly instead of #one# value. Like this 'aAbcArray.value' Rauf
Tjarko - that is a good point, I didn't think of that... I'm not sure why you can't get view the code in your RSS reader... I am pretty sure its all valid xml, I'll look into it. -pete
how about "cannot read your messages (bad data 1) what's with that?


foundeo