Skip to main content
Participant
August 31, 2008
Question

SQL Query

  • August 31, 2008
  • 1 reply
  • 1774 views
I applogize if i am in the incorrect area I have been racking my brain on this I must admit I am more of a graphic artis then programmer. I am using Coldfussion with a MS Access database and need to have an Item page that when first viseted or clicking on the all selection that it dirplays all the records in the recordset. Then when you click on a catagory label it then filters the recordset. I tired to filter multiple colums but becuase the other filter has to have a defaul valuse set to it it automatically filters the catagory to 1. is theri a way to dissabel the filter and apply it only when a Query String is sent.

SELECT *
FROM Items
WHERE filter = #FORM.A#
AND categoryID = #categoryID# <------ this is the string varible i want to only query when sent through

I am probably missing alot of code but any help or suggestions would be greatly appreciated.
thanks
Shannon
This topic has been closed for replies.

1 reply

Inspiring
August 31, 2008
If it is a URL parameter:

SELECT *
FROM Items
WHERE filter = #FORM.A#
<cfif isDefined("URL.categoryID")>
AND categoryID = <cfqueryparam value="#URL.categoryID#"
cfsqltype="cf_sql_numeric">
</cfif>

If it is a form parameter:

SELECT *
FROM Items
WHERE filter = #FORM.A#
<cfif isDefined("FORM.categoryID")>
AND categoryID = <cfqueryparam value="#FORM.categoryID#"
cfsqltype="cf_sql_numeric">
</cfif>

And you really need to be using <cfqueryparam>

http://livedocs.adobe.com/coldfusion/8/htmldocs/queryDB_5.html#1142383

--
Ken Ford
Adobe Community Expert Dreamweaver/ColdFusion
Adobe Certified Expert - Dreamweaver CS3
Fordwebs, LLC
http://www.fordwebs.com


"shobek_" <webforumsuser@macromedia.com> wrote in message
news:g9cras$1rt$1@forums.macromedia.com...
>I applogize if i am in the incorrect area I have been racking my brain on
>this
> I must admit I am more of a graphic artis then programmer. I am using
> Coldfussion with a MS Access database and need to have an Item page that
> when
> first viseted or clicking on the all selection that it dirplays all the
> records
> in the recordset. Then when you click on a catagory label it then filters
> the
> recordset. I tired to filter multiple colums but becuase the other filter
> has
> to have a defaul valuse set to it it automatically filters the catagory to
> 1.
> is theri a way to dissabel the filter and apply it only when a Query
> String is
> sent.
>
> SELECT *
> FROM Items
> WHERE filter = #FORM.A#
> AND categoryID = #categoryID# <------ this is the string varible i want
> to
> only query when sent through
>
> I am probably missing alot of code but any help or suggestions would be
> greatly appreciated.
> thanks
> Shannon
>

shobek_Author
Participant
August 31, 2008
Thank you for responding I tried the line of code you provided and get the following errors,

Error Occurred While Processing Request

Error Executing Database Query.

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

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

If I am not providing the correct or have explained my issued incorrectly please bear with me.
Thanks Again
Shannon