Query Works in ACCESS DB but not on Front End

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

  1. #1

    Default Query Works in ACCESS DB but not on Front End

    Okay...i am trying to run a query to view people that are overdue in there
    medical appts. i did the <cfoutput> in place of <cfquery> and ran the query in
    ACCESS. It works and it shows the view that i want. however, i get the
    following error:

    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Too few parameters. Expected 1.

    The error occurred in \\server_name\squadron_overdue.cfm: line 121

    119 : <span class="style1"><br>
    120 : </span>
    121 : <cfquery name="GetOverdue" datasource="myDSN">
    122 : SELECT name, rank, imm_stat, den_stat, den_class, pha_stat, lab_stat,
    dna_stat, hiv_stat, action_items
    123 : FROM Wing_Data



    --------------------------------------------------------------------------------

    SQL SELECT name, rank, imm_stat, den_stat, den_class, pha_stat, lab_stat,
    dna_stat, hiv_stat, action_items FROM Wing_Data WHERE Wing_Data.Unit='43
    COMMUNICATIONS SQ' And Wing_Data.PHA_stat="R" Or DEN_STAT="R" Or DEN_CLASS="R"
    Or PHA_STAT="R" Or LAB_STAT="R" Or DNA_STAT="R" Or HIV_STAT="R";
    DATASOURCE myDSN
    VENDORERRORCODE -3010
    SQLSTATE 07002

    First i'm on a page that shows all records, overdue or not. Well i have a
    button you click to view overdue records only. you click the button and it
    takes you to the squadron_overdue.cfm page. Thats when the error obviously
    occurs. Here's my query:

    <cfquery name="GetMedical" datasource="myDSN">
    SELECT name, rank, imm_stat, den_stat, den_class, pha_stat, lab_stat,
    dna_stat, hiv_stat, action_items
    FROM Wing_Data
    WHERE Wing_Data.Unit='43 COMMUNICATIONS SQ' And Wing_Data.PHA_stat="R" Or
    DEN_STAT="R" Or DEN_CLASS="R" Or PHA_STAT="R" Or LAB_STAT="R" Or DNA_STAT="R"
    Or HIV_STAT="R";
    </cfquery>



    and here's my <cfoutput>: (the if statements change the information from the
    database to the corresponding color: RED, YELLOW, OR GREEN) THATS WHAT THE SPAN
    CLASSES ARE.)

    <CFOUTPUT query="GetMedical">
    <tr>
    <td><span class="style34">#name#</span></td>
    <td><span class="style34">#rank#</span></td>
    <td><span class="style34"><cfif '#imm_stat#' eq "R"><span
    class="style43"><cfelseif '#imm_stat#' eq "Y"><span class="style42"><cfelseif
    '#imm_stat#' eq "g"><span class="style41">
    </cfif>#imm_stat#</span></td>
    <td><span class="style34"><cfif '#den_stat#' eq "R"><span
    class="style43"><cfelseif '#den_stat#' eq "Y"><span class="style42"><cfelseif
    '#den_stat#' eq "g"><span class="style41">
    </cfif>#den_stat#</span></td>
    <td><span class="style34"><cfif '#den_class#' eq "4"><span
    class="style43"><cfelseif '#den_class#' eq "3"><span class="style42"><cfelseif
    '#den_class#' eq "2" or "1"><span class="style41">
    </cfif>#den_class#</span></td>
    <td><span class="style34"><cfif '#pha_stat#' eq "R"><span
    class="style43"><cfelseif '#pha_stat#' eq "Y"><span class="style42"><cfelseif
    '#pha_stat#' eq "g"><span class="style41">
    </cfif>#pha_stat#</span></td>
    <td><span class="style34"><cfif '#lab_stat#' eq "R"><span
    class="style43"><cfelseif '#lab_stat#' eq "Y"><span class="style42"><cfelseif
    '#lab_stat#' eq "g"><span class="style41">
    </cfif>#lab_stat#</span></td>
    <td><span class="style34"><cfif '#dna_stat#' eq "R"><span
    class="style43"><cfelseif '#dna_stat#' eq "Y"><span class="style42"><cfelseif
    '#dna_stat#' eq "g"><span class="style41">
    </cfif>#dna_stat#</span></td>
    <td><span class="style34"><cfif '#hiv_stat#' eq "R"><span
    class="style43"><cfelseif '#hiv_stat#' eq "Y"><span class="style42"><cfelseif
    '#hiv_stat#' eq "g"><span class="style41">
    </cfif>#hiv_stat#</span></td>
    <td><span class="style34"><cfif '#action_items#' eq "R"><span
    class="style43"><cfelseif '#action_items#' eq "Y"><span
    class="style42"><cfelseif '#action_items#' eq "g"><span class="style41">
    </cfif>#action_items#</span></td>
    </tr>
    </CFOUTPUT>


    Please Help! Thx

    coryd218 Guest

  2. Similar Questions and Discussions

    1. Query is slowest, why it works always with the index
      I have a query that it orders to me for date, and is fastest. Then in an other query I must order for an other field (char (3)) and is slowest,...
    2. Join Query works in access but not via ColdFusion
      I have a query I built with the query builder in Access and through access it works fine. here is the query: SELECT appUsers.AppId,...
    3. Query works in fine CF5 but not CFMX
      I have a simple query against an Oracle database that works in CF 5 but not in CFMX. In CF 5 I get one record which is what I want, but in CFMX I...
    4. sql-query works alone but not in function...
      Hy, My english is not the best, so if you donīt understand something, please ask! I want to print the content of a mysql-table where a field...
    5. BCP query out executed by xp_cmdshell works fine from query analyzer but fails from VB Component
      Hi all, I have a stored procedure which returns a vast number of record and i have to write the output into a csv file. I'm using BCP utility to...
  3. #2

    Default Re: Query Works in ACCESS DB but not on Front End

    For one thing you can't use double quotes around cfquery values.
    DEN_STAT="R" for example should be DEN_STAT='R' also you should
    enclose your AND and OR clauses in brackets so there is no ambiguity. Does
    A=1 and B=2 OR C=3 OR D=4 mean
    (A=1 and B=2) OR (C=3 OR D=4)
    (A=1) and (B=2 OR C=3) OR (D=4)
    Results can be different depending on how they are grouped.


    OldCFer Guest

  4. #3

    Default Re: Query Works in ACCESS DB but not on Front End

    There's nothing wrong with using "<" . It's a standard comparison operator in
    SQL.
    There's no other way to say less than. As for your dates, they will always
    contain time.
    That's normal. The way you set the format , "short date", just affects the way
    Access
    will display it in Access. Just use the cf
    DateFormat(qry.datevalue,"mm/dd/yy") to
    display it in your application.

    OldCFer 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