Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
drmaves #1
CFC Query not returning recordcount
I wrote a CFC that performs a simple query. After the CFC runs the query I try
to check for the recordcount in the calling template and get the following
error:
Element RECORDCOUNT is undefined in CHECKTITLE.
Why can't I check the recordcount?
Here's the CFC function code:
<cffunction name="checkTitle"
displayname="Check Title"
hint="Check Title"
returntype="query"
output="false">
<cfargument name="titlename"
required="yes">
<cfset var CheckTitle="">
<cfquery name="CheckTitle" datasource="#application.dsn#">
SELECT *
FROM title
WHERE name = '#titlename#'
</cfquery>
<cfreturn CheckTitle>
</cffunction>
Here's the call:
<cfinvoke
component="components.title"
method="checkTitle"
titlename="#form.name#">
</cfinvoke>
Here's where I check the recordcount:
<cfif CheckTitle.recordcount EQ 0 and url.function EQ "A">
drmaves Guest
-
SQL Query Not Returning Correct Results
I am trying to pull all records that are set for mailing and are from every state except for Nebraska and some counties in Iowa. It isn't pulling... -
Getting recordcount from resultset of 'union' query
Hi, I need to find out the number of records in the resultset of a union of 2 queries. E.g. "select ID from Pages where numPageCatID = " &... -
Problem returning query when multiple checkboxes areselected
I am having a problem (I get no error message but no records are returned) when more than one checkbox is selected (Year), Works fine (returns... -
query loop not returning
<CFQUERY Name ="getweight" DATASOURCE = #application.dsn#> SELECT * FROM Products Where name = '#Session.CrtProductName#' </cfquery> <cfloop... -
query not returning
Can anyone tell me whats wrong with this code? The variables are being past from other page and the $connection is ok as is $result. this query... -
The ScareCrow #2
Re: CFC Query not returning recordcount
Your main problem is that you don't have a "returnVariable" in the cfinvoke
<cfinvoke component="components.title" method="checkTitle"
titlename="#form.name#" returnVariable="rtnQuery"></cfinvoke>
Then you use the returnVariable to access the query, so the call would be
<cfif rtnQuery.recordcount EQ 0 and url.function EQ "A">
I would also suggest you develop a naming convention. You have everthing
called "CheckTitle" and I would assume at some point CF will not know which
"CheckTitle" your talking about.
Ken
The ScareCrow Guest
-



Reply With Quote

