Current Position:Home > Why the error in one, but not the other

Why the error in one, but not the other

Update:10-11Source: network consolidation
Advertisement
Why does this code Generate the error:
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 in
C:\Inetpub\wwwroot\2onboard\kBookList.cfm: line 40
38 : <tr>
39 : <td colspan="6">
40 : <cfif showList IS NOT "yearly"><a class="nav"
href=""> Yearly  </a>  </cfif>
41 : <cfif showList IS NOT "complete"><a class="nav"
href=""> Complete  </a>  </cfif>
42 : <cfif showList IS NOT "wish"><a class="nav"
href=""> Wish
List  </a>  </cfif>
CODE.........
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>2onboard.com - Kevin's Korner - Book
List</title>
<!--- SET DEFAULT VARIABLES --->
<cfparam name="showList" default="complete">
<cfparam name="showOrder" default="title">
<cfparam name="showStatus" default="own">
<!--- QUERIES --->
<cfquery name="showList" datasource="2onboard">
SELECT
title,author,status,completed,pages,queue,rating,cover,series,book,link
FROM books
WHERE status = '#showStatus#'
ORDER BY '#showOrder#'
</cfquery>
</head>
<body>
<div id="container"> <!--- GRAY ALL ENCOMPASING BOX
--->
<cfinclude template="header.cfm"> <!--- HEADER
--->
<cfinclude template="explanation.cfm"> <!---
EXPLANITION OF SCREEN BOX --->
<div class="raised"> <!--- CONTENT OF - HOME PAGE
--->
<b class="top"><b class="b1"></b><b
class="b2"></b><b class="b3"></b><b
class="b4"></b></b>
<div class="boxcontent">
<div class="boxcontenttext">
<table cellspacing="0">
<tr>
<td><span class="title">Kevin's
Korner</span><b> - Reading</b></td>
<td colspan="5"
align="right"><cfoutput> Library contains
<b>#showList.recordCount#</b>
books</cfoutput></td>
</tr>
<tr><td colspan="6"><span
class="spacetext"> </span></td></tr>
<tr>
<td colspan="6">
<cfif showList IS NOT "yearly"><a class="nav"
href=""> Yearly  </a>  </cfif>
<cfif showList IS NOT "complete"><a class="nav"
href=""> Complete  </a>  </cfif>
<cfif showList IS NOT "wish"><a class="nav"
href=""> Wish
List  </a>  </cfif>
</td>
CODE CONTINUES ON FROM HERE….
BUT, if I take just the bare minimum and test it as the
following, it works fine - WHY?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<cfparam name="showList" default="complete">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title> </title>
</head>
<body>
<cfif showList IS NOT "yearly"><a class="nav"
href=""> Yearly  </a>  </cfif>
<cfif showList IS NOT "complete"><a class="nav"
href=""> Complete  </a>  </cfif>
<cfif showList IS NOT "wish"><a class="nav"
href=""> Wish
List  </a>  </cfif>
</body>

The Best Answer

Advertisement
> <cfparam name="showList" default="complete">
This line creates showList as a simple string variable
containing
"complete".
> <cfquery name="showList" datasource="2onboard">
This line redefines showList as a recordset containing the
data returned
from the database which is not a simple variable and can not
be accessed
with code such as <cfoutput>#showList#</cfoutput>
> <cfparam name="showList" default="complete">
This line does NOT redefine showList back to a simple string
because a
<cfparam ...> only fires if the variable does not
exist. The previous
two lines would create the variable, thus it exists.
jkgiven wrote:
> Why does this code Generate the error:
>
> 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 in
C:\Inetpub\wwwroot\2onboard\kBookList.cfm: line 40
>
> 38 : <tr>
> 39 : <td colspan="6">
> 40 : <cfif showList IS NOT "yearly"><a
class="nav"
>
href=""> Yearly  </a>  </cfif>
> 41 : <cfif showList IS NOT "complete"><a
class="nav"
>
href=""> Complete  </a>  </cfif>
> 42 : <cfif showList IS NOT "wish"><a
class="nav" href=""> Wish
>
List  </a>  </cfif>
>
>
> CODE.........
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
> "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="
http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
> <title>2onboard.com - Kevin's Korner - Book
List</title>
>
> <!--- SET DEFAULT VARIABLES --->
> <cfparam name="showList" default="complete">
> <cfparam name="showOrder" default="title">
> <cfparam name="showStatus" default="own">
>
> <!--- QUERIES --->
> <cfquery name="showList" datasource="2onboard">
> SELECT
title,author,status,completed,pages,queue,rating,cover,series,book,link
> FROM books
> WHERE status = '#showStatus#'
> ORDER BY '#showOrder#'
> </cfquery>
>
> </head>
>
> <body>
>
> <div id="container"> <!--- GRAY ALL ENCOMPASING
BOX --->
> <cfinclude template="header.cfm"> <!--- HEADER
--->
> <cfinclude template="explanation.cfm"> <!---
EXPLANITION OF SCREEN BOX --->
>
> <div class="raised"> <!--- CONTENT OF - HOME
PAGE --->
> <b class="top"><b class="b1"><b
class="b2"><b class="b3"><b
> class="b4">
> <div class="boxcontent">
> <div class="boxcontenttext">
> <table cellspacing="0">
> <tr>
> <td><span class="title">Kevin's
Korner</span>
- Reading</td>
> <td colspan="5"
align="right"><cfoutput> Library contains
>
#showList.recordCount# books</cfoutput></td>
> </tr>
> <tr><td colspan="6"><span
class="spacetext"> </span></td></tr>
> <tr>
> <td colspan="6">
> <cfif showList IS NOT "yearly"><a class="nav"
>
href=""> Yearly  </a>  </cfif>
> <cfif showList IS NOT "complete"><a class="nav"
>
href=""> Complete  </a>  </cfif>
> <cfif showList IS NOT "wish"><a class="nav"
href=""> Wish
>
List  </a>  </cfif>
> </td>
>
> CODE CONTINUES ON FROM HERE?.
>
> BUT, if I take just the bare minimum and test it as the
following, it works
> fine - WHY?
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
> "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="
http://www.w3.org/1999/xhtml">
>
> <cfparam name="showList" default="complete">
>
> <head>
> <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
> <title> </title>
> </head>
>
> <body>
>
> <cfif showList IS NOT "yearly"><a class="nav"
>
href=""> Yearly  </a>  </cfif>
> <cfif showList IS NOT "complete"><a class="nav"
>
href=""> Complete  </a>  </cfif>
> <cfif showList IS NOT "wish"><a class="nav"
href=""> Wish
>
List  </a>  </cfif>
>
> </body>
>
>
>
  • Error in starting Adobe Bridge in Photoshop CS2 Update:10-11

    I've just installed Photoshop CS2, however upon opening Adobe Bridge this error message appears " The application has failed to start because libagluc28.dll was not found. Reinstalling to application may fix the problem" I have reinstalled and c

  • Windows Vista: Ipod Error Message, no longer read by PCs Update:10-11

    Hello, I have a 5th generation black ipod video with 30GB of memory. The other day I hooked it up to my laptop (Toshiba, 4 months old) that it's been functioning on with no problems whatsoever. This weird error message flashed twice about it not bein

  • Error while offsetting a variable Update:10-11

    Hello Experts I want to display the data for last 5 years in my query. So I tried using the SAP exit variable Current Calendar Year (0CYEAR) and the offset it by 5. However, I am getting the following error message for the query "System error in prog

  • Safari doesn't open and comes up with this error report. Update:10-11

    Please help. Process:         Safari [474] Path:            /Applications/Safari.app/Contents/MacOS/Safari Identifier:      com.apple.Safari Version:         7.0.4 (9537.76.4) Build Info:      WebBrowser-7537076004000000~3 Code Type:       X86-64 (Na

  • I click on itunes but doesnt open and says send error report or dont send Update:10-11

    i click on itunes but doesnt open and says send error report or dont sendYou will need to provide more details as we cannot see your computer screen. Does this happen every time you launch LabVIEW? What version of LabVIEW are you using? What version

  • If image file not exist in image path crystal report not open and give me exception error problem Update:10-11

    Hi guys my code below show pictures for all employees code is working but i have proplem if image not exist in path crystal report not open and give me exception error image file not exist in path although the employee no found in database but if ima

  • Open vi error for report generation toolkt Update:10-11

    Originally it works fine. Now I upgrade to win7, LV9 and office2010. To open the old program by 8.6.1, I reinstalled LV 8.6.1 and report generation toolkit. But still got the error as attached. Any suggestion, thanks. Attachments: ss.png ‏184 KB1. MS

  • Error in cast a variable Update:10-11

    these are few lines from my long STORED PROCEDURE actually i am new to oracle 11g please declare v_s nvarchar2(10); p_RN nvarchar2(10); begin v_s := v_s || cast(p_RN as nvarchar2(10)); - ERROR IS COMING IN THIS LINE end; error ORA-06550: line 5, colu

  • Error while Creating Presentation variable Update:10-11

    Hi,I am new to OBIEE I am facing this error: "A numeric value was expected (received "max("Sales Measures".Dollars)"). Error Details Error Codes: EHWH2A7E" 1.I am using paint rpd.I want to use presentation variable. 2.So i to

  • Error message into a Variable. Update:10-11

    Dear users, I have a rather usual (unusual from the weekend beers for me though!!) query which I can't figure out a proper way to implement. My requirement is like this: I have a message class in which I want to define a text 'Employee number & not f