Trouble with url variable in query

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default Trouble with url variable in query

    Hi there,

    I'm having trouble getting a database query that uses url variables to work.

    The query is

    <cfquery Name="Display" datasource="Products">
    SELECT ProductType, ProductInfo, CategoryType, CategoryInfo, ItemName,
    ItemInfo, Price, Weight
    FROM tblProducttype, TblCategorytype, TblItems
    WHERE TblProducttype.ProductCode = tblCategorytype.ProductCode
    AND tblCategorytype.CategoryCode = tblItems.CategoryCode
    AND tblCategorytype.ProductCode = <cfqueryparam value="#URL.cat#"
    cfsqltype="cf_sql_integer">
    AND tblCategorytype.CategoryCode = <cfqueryparam value="#URL.type#"
    cfsqltype="cf_sql_varchar">
    AND tblItems.Available = "True"
    </cfquery>

    The error I'm getting is

    Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Too few parameters. Expected 3.

    The error occurred in C:\CFusionMX\wwwroot\Mother Earth's Goodies\Main.cfm:
    line 9

    7 : AND tblCategorytype.CategoryCode = tblItems.CategoryCode
    8 : AND tblCategorytype.ProductCode = <cfqueryparam value="#URL.cat#"
    cfsqltype="cf_sql_integer">
    9 : AND tblCategorytype.CategoryCode = <cfqueryparam value="#URL.type#"
    cfsqltype="cf_sql_varchar" >
    10 : AND tblItems.Available = "True"
    11 : </cfquery>

    Any help would be appreciated





    Vampyr_Bytes Guest

  2. Similar Questions and Discussions

    1. PARSING A QUERY OF QUERY WITH A VARIABLE VALUE
      On my first page the user selects a project. I am using the variable SelectedProject: <cfset SelectedProject =...
    2. query trouble
      i'm just getting started here, and am having trouble building queries. after filling in the information tables, i press the 'ok' button, and this...
    3. Trouble with sql query
      Hi, I'm sending the follwoing query to mysql from a php script: ...
    4. Trouble with database query
      Hi, THIS (Below) error keeps coming. I'm just trying to make a normal login page. It LOOKS fine to me, I've groomed it for bad spaces and...
    5. Trouble getting data to my DB from the cfinput tag query
      if you simply view the screen shots linked here, http://www.e-nationmusic.com/code_views/insert_data.htm which are at the bottom of the entire code...
  3. #2

    Default Re: Trouble with url variable in query

    Sometimes teh line reference is indication of the error, and sometimes it is
    indication of the last place everything made sense.

    I think it actually may be the latter and the issue is in Line 10.

    Access has a few quirky things with it that are different from standard SQL.

    Is the "tblItems.Available" field a YES/NO field? If so, then it needs to read:
    10 : AND tblItems.Available = 1

    If it is any string field where it is actually looking for the word "TRUE",
    you need to use single quotes, not double:
    10 : AND tblItems.Available = 'True'

    If the problem is actually in Line 9 thyen it is because you are specifying a
    string variable but have no single quotes around the output from the
    cfqueryparam. In standard SQL (ie MSSQL) you can actually get away with not
    usuing proper quotes etc and the server will figure it out, but MS ACCESS won't
    allow it.

    Without the actual database to run the tests against, these would be my best
    suggestions for now.




    SafariTECH Guest

  4. #3

    Default Re: Trouble with url variable in query

    Thanks :) It was line 10.
    Vampyr_Bytes 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