CFC Query not returning recordcount

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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 = " &...
    3. 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...
    4. query loop not returning
      <CFQUERY Name ="getweight" DATASOURCE = #application.dsn#> SELECT * FROM Products Where name = '#Session.CrtProductName#' </cfquery> <cfloop...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default Re: CFC Query not returning recordcount

    Thanks, that did the trick!
    drmaves Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139