Data type mismatch in criteria expression

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

  1. #1

    Default Data type mismatch in criteria expression

    the Access database data typs for the 'active' and 'officer' fields are
    datatype Yes/No

    ---------------------------------------EmTiDOHActOff.cfm
    --------------------------------------------------------------------

    <form action = "EmTiDOHActOff_action.cfm" method = "post">
    <table>
    <tr>
    <td>Email Address:</td><td colspan="3"><input name = "email" type =
    "text"></td>
    </tr>
    <tr>
    <td>Title:</td><td><input type "text" name = "title"></td>
    <td>Date of Hire:</td><td><input type = "text" name = "DOH"></td>
    </tr>
    <tr>
    <td rowspan="2">Is this employee active?</td><td><input type = "radio" name
    = "active" value = "Yes">Yes</td>
    </tr>
    <tr>
    <td><input type = "radio" name = "active" value = "No">No</td>
    </tr>
    <tr>
    <td rowspan="2">Is this employee an officer?</td><td><input type = "radio"
    name = "officer" value = "Yes">Yes</td>
    </tr>
    <tr>
    <td><input type = "radio" name = "officer" value = "No">No</td>
    </tr>
    </table>
    <input type = "submit" name = "Save" value = "Save Record">


    --------------------------------------------------------------------------------
    -------------------------------------------
    ---------------------------------------EmTiDOHActOff_action.cfm
    --------------------------------------------------------------------



    <cfquery datasource = "testdevemp" name = "addinfo">
    insert into emp (email, title, hiredate, active, officer)
    values ('#form.email#', '#form.title#', '#form.DOH#',
    '#form.active#', '#form.officer#')
    </cfquery>

    _-------------------------------------------------------------------------------
    --------------------------------------------------
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Data type mismatch in criteria expression.

    The error occurred in D:\Inetpub\wwwroot\TestDev\EmTiDOHActOff_action.cf m:
    line 12

    10 : insert into emp (email, title, hiredate, active, officer)
    11 : values ('#form.email#', '#form.title#', '#form.DOH#',
    12 : '#form.active#', '#form.officer#')
    13 : </cfquery>

    Captain Ru Guest

  2. Similar Questions and Discussions

    1. Access database getting mismatch data on criteria
      Hello, It's been a while since I used ad Access DB with CF so, forgive my memory lapse. But, can anyone explain why this query is throwing the...
    2. Datatype mismatch in criteria expression
      All, Any help you can lend on this would be greatly appreciated. I am not a coldfusion coder by any means and have stumbled into this problem at a...
    3. Access data type mismatch for empty form field
      Hello Everyone; I'm using an MS Access DB on a CFMX (CF 6) site...and updating records in a db from a form ..the CFM for code looks like : ...
    4. data type mismatch error...
      HI guys, getting pretty stressed with this haha! it's probably something simple...right I have this registration form that does multiple checks...
    5. Type mismatch in expression
      Dear anyone, I used the wizard to make a form, but when I try to go from design view to form view an eooro message comes up "Type mismatch in...
  3. #2

    Default Re: Data type mismatch in criteria expression

    Don't use single quotes when inserting into an Access yes/no field. By putting
    single quotes around the value, the db interprets it as a "text" value and not
    boolean (i.e. YES/NO, TRUE/FALSE).

    --- correct way (no single quotes)
    INSERT INTO yourTable ( yourYesNoField )
    VALUES ( YES )

    --- causes error
    INSERT INTO yourTable ( yourYesNoField )
    VALUES ( 'YES' )



    mxstu Guest

  4. #3

    Default Re: Data type mismatch in criteria expression

    yes/no values in access are stored as 0/-1 so insert a boolean value
    0=no, 1=yes
    do not use quotes around numeric values
    insert into emp (email, title, hiredate, active, officer)
    values ('#form.email#', '#form.title#', '#form.DOH#', #form.active#,
    '#form.officer#')

    HTH

    --
    Tim Carley
    [url]www.recfusion.com[/url]
    [email]info@NOSPAMINGrecfusion.com[/email]
    Mountain Lover Guest

  5. #4

    Default Re: Data type mismatch in criteria expression

    Awesome! I swear I tried that before, but that must have been before I isolated the code segment.

    Much appreciated.
    Captain Ru 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