CFIF return RecordCount EQ 0

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default CFIF return RecordCount EQ 0

    Hi - need to check if there is a record in a MySQL database. If there is
    display it if there not show a default Address. Here's what I have. It doen't
    work though. Any ideas? <cfquery name='qGetSomeData'
    datasource='SQL_ServerDS_Name'> SELECT 'A' AS B </cfquery>
    <cfoutput> <cfif qGetSomeData.RecordCount EQ 0> <h2>There ain't
    no such data rows (neither)!</h2> <cfelse> ... Displaying my
    results here ... </cfif> </cfoutput>

    bpiersant Guest

  2. Similar Questions and Discussions

    1. Dynamic RecordCount
      I am looping through a list of sites and counting the number of articles live and pending. I'd like to be able to refer to the RecordCount for...
    2. Indirect recordcount
      I have a variable that contains the name of a query. How can I get the RecordCount for that query? I've tried using Evaluate() in several...
    3. Getting a recordcount
      Hi I have opened a database in PHP and would like to know whether a particular record exists. i.e. $ThisUsername = $_REQUEST;...
    4. recordset.recordcount return allways -1 on select statements
      Greetings On my ASP application I want to retrieve the number (Recordset.recordCount property) of records affected by a select statement, but I...
    5. recordcount -1
      I'm simply trying to get a number of records returned in a recordset, and just get a -1. I have looke din a few books and other references, can't...
  3. #2

    Default Re: CFIF return RecordCount EQ 0

    That should work.

    Try <cfdump var="#qGetSomeData#"> to see what's being returned to the query.
    cf_menace Guest

  4. #3

    Default Re: CFIF return RecordCount EQ 0

    Instead of SELECT 'A' AS B, do a real query from a table in the database.

    Once you do query a table, do this : -

    <cfif qGetSomeData.RecordCount>
    <cfoutput query="qGetSomeData">
    ....display results......
    </cfoutput>
    <cfelse>
    <h2>Empty!</h2>
    </cfif>


    Sameer 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