Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query a database for Categories

Status
Not open for further replies.

jasonkeller

Programmer
May 23, 2001
16
US
I have an Access database populated with information such as an autonumber,name,productid,category,subcategory.
I need to use a pull down on an admin page to select which category to edit. This is just my form for pulling up active categories. The User then selects from the list and submits. The next page populates all the products in that category. See the next code example

Admin Page
-----------------------------------------------------------
<form method=&quot;get&quot; action=&quot;displaylist.cfm#category#&quot;>
<select name=&quot;category&quot;>
<cfoutput query=&quot;modify&quot;>
<option value=&quot;#category#&quot;>#category#</option></cfoutput>
</select>
<input type=&quot;SUBMIT&quot; value=&quot;Edit Category&quot;>
-----------------------------------------------------------

Display Category Product List
-----------------------------------------------------------
<cfapplication name=&quot;dacategoryinquestion&quot; sessionmanagement=&quot;Yes&quot;>

<cfif ParameterExists(URL.category) IS 'Yes'>
<cfset SESSION.dacategory = '#URL.category#'>
</cfif>

<CFQUERY NAME=&quot;all&quot; DATASOURCE=&quot;mjgrant&quot;>
SELECT *
FROM products
WHERE category = #SESSION.dacategory#
</CFQUERY>
-------------------------------------------------------

I am getting a this error...

Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression

What am I missing.
 
Hey jason,

Anytime I get a &quot;Type Mismatch&quot; error I try putting quotes. I'm not really clear on the exact rules of this but I believe that if you are comparing strings you need quotes so try this:

<CFQUERY NAME=&quot;all&quot; DATASOURCE=&quot;mjgrant&quot;>
SELECT *
FROM products
WHERE category = '#SESSION.dacategory#'
</CFQUERY>

That should do it for you. I'm assuming the category is a string rather then an integer.

Hope it fixes it.

Have fun...

 
Thanks tlhawkins, I should have know that. I think I was looking to deep into.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top