Professional Web Applications Themes

Validation of records - Coldfusion Database Access

How can i validate if a record number in the Database NOT exist, and that an error message will be returned to the user, that a wrong number has been entered. The code i'm having sofar is : <cfparam name="FORM.issue_number" default="1"> <cfquery name="rs_issue" datasource="issue"> SELECT * FROM tbl_issue WHERE issue_number = #FORM.issue_number# </cfquery>...

  1. #1

    Default Validation of records

    How can i validate if a record number in the Database NOT exist, and that an
    error message will be returned to the user,
    that a wrong number has been entered.

    The code i'm having sofar is :
    <cfparam name="FORM.issue_number" default="1">
    <cfquery name="rs_issue" datasource="issue">
    SELECT *
    FROM tbl_issue
    WHERE issue_number = #FORM.issue_number#
    </cfquery>

    whatsaname Guest

  2. #2

    Default Re: Validation of records

    Run a select query and use the recordcount variable.

    Or run a select count(fieldname) as thecount query with the appropriate where
    clause and use the queryname.thecount value.

    Originally posted by: whatsaname
    How can i validate if a record number in the Database NOT exist, and that an
    error message will be returned to the user,
    that a wrong number has been entered.

    The code i'm having sofar is :
    <cfparam name="FORM.issue_number" default="1">
    <cfquery name="rs_issue" datasource="issue">
    SELECT *
    FROM tbl_issue
    WHERE issue_number = #FORM.issue_number#
    </cfquery>



    Dan Bracuk Guest

  3. #3

    Default Re: Validation of records

    <cfparam name="FORM.issue_number" default="">
    <cfquery name="rs_issue" datasource="issue">
    SELECT *
    FROM tbl_issue
    WHERE issue_number = #FORM.issue_number#
    </cfquery>

    <cfif not rs_issue.recordcount>
    No records found.
    </cfif>

    _silence Guest

  4. #4

    Default Re: Validation of records

    I'm not that familar with database quiries rahter than the simple recordsets.
    I've tried to find how to make the quiry that runs the RECORDCOUNT, but i can
    not find that.
    Could you please assist me a bit?

    Thanks

    whatsaname Guest

  5. #5

    Default Re: Validation of records

    All queries ran with cfquery return the following variables in the query scope:
    query_name.currentRow
    Current row of query that cfoutput is processing
    query_name.columnList
    Comma-delimited list of the query columns
    query_name.RecordCount
    Number of records (rows) returned from the query
    cfquery.ExecutionTime
    ulative time required to process the query

    They can all be referenced in CF after the query is executed by using
    query_Name.recordcount (where query_Name is the actual name of your query),
    etc...

    For more information see:

    [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-b19.htm[/url]

    _silence Guest

  6. #6

    Default Re: Validation of records

    Thank you so much, now i've got the clue, and it is working.
    I've place the CFIF where thhe output is expected
    ("<cfoutput>#Form.issue_number# <cfif not rs_issue.recordcount>
    DOES NOT EXIST</cfif></cfoutput>"

    Again Great Help.

    whatsaname Guest

  7. #7

    Default Re: Validation of records

    That is a good one. Thanks for your help.
    whatsaname Guest

Similar Threads

  1. CFFORM Validation trumping Custom Form Validation
    By Beals in forum Macromedia ColdFusion
    Replies: 17
    Last Post: July 19th, 06:40 PM
  2. CFFORM validation trumping Custom Validation
    By Beals in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: July 16th, 11:33 PM
  3. 'Either Or' Validation
    By dnaguy in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: March 12th, 03:31 PM
  4. Replies: 0
    Last Post: June 25th, 03:05 PM
  5. only custom validation control does server side validation?
    By Colin Mackay in forum ASP.NET General
    Replies: 0
    Last Post: June 25th, 07:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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