0

I'm getting my query output in modal and handler but when it comes to view it is saying

can't cast complex object type query :string

in my coldbox

rrk
  • 15,677
  • 4
  • 29
  • 45
SREERAM
  • 1
  • 4

1 Answers1

0

I assume you are trying to print something. The error is because to you can't print complex objects (query,structure,array, etc..) like that. So you have print it as #yourQueryName.columnName#. You can dump a complex object, but can't print it.

For example.

<cfset myQry = queryNew("Name,Age","varchar,integer",[{name='kannan',age="29"}])>

Now you can print the query data like

<cfoutput>MyName: #myQry.name# <br/>
    MyAge: #myQry.age#<br/>
</cfoutput>

But you can't directly print #myQry# or it will return the error you're seeing. Instead, you can dump the query like this <cfdump var="#myQry#" />.

Hopefully that will help you.

SOS
  • 6,430
  • 2
  • 11
  • 29
Kannan.P
  • 1,263
  • 7
  • 14
  • 1
    You can only access `query.columnName` if you have an iteration context (e.g. ``). To access a query without iteration context, you have to specify the row as well: `query["columnName"][rowIndex]` – Alex Aug 04 '18 at 12:09
  • *You can only access query.columnName if you have an iteration context* More specifically, you can only access the values within the first row of a query. Anything else requires some sort of loop or specifying a row number. – SOS Aug 06 '18 at 14:55