This topic is locked

Using DISTINCT to display categories?

6/23/2006 12:38:06 PM
ASPRunnerPro General questions
S
Spitty author

Hello, can anyone help me out! A table has 'Title, Description, Image and Category', there are set categories from a drop down list within the add page i.e. ford, bmw, merc etc. I want to be able to navigate from the 'menu.asp' page to display only the DISTINCT categories within the table.

So.. within the menu page i would have a list of links such as: Ford, BMW, Merc etc. When i click for example 'BMW' on one of these the _list.asp page would only display records with BMW as there category.
How would i go about doing this?
Thanks for any help!!
Joe

K
kat 6/26/2006

Joe,
you can use Add table view option on the Datasource tab in ASPRunnerPro.

  • Create additional table view Categories for your Main table.
  • On the Choose fields tab (Step6) choose only one field Category to appear.
  • Return to the Datasource tab and uncheck Create menu item for this table check-box for the Main table.

    Set master-detail relationship: set Categories like Master for Main table and set Category field like Primary and Foreign keys.

S
Spitty author 6/26/2006

Thank you for your help, and im a bit closer to understanding how to do it howerver... i wanted the menu page to have the distinct categories rather than just a 'category' link.
To explain further... in the menu.asp page i would like the links to my Main Tables (where all records are displayed in any order) and under that i would also like categories where they could click for example BMW, and a table would be displayed with the exact same table columns (title, description, image etc) but only display records that have the category value = to BMW. Basically querying the main table to display certain records.

I could make several table views, each with there own sql i.e. select * from blabla where Category='BMW' however there are about 20 set categories. how can i query one _list.asp file to display certain records from the menu.asp.
Hopefully i havent actually confused the hell out of you! I want it set up this way so they can easy navigate to a certain vehicle model i.e. BMW and they can only see the BMW's they have in there single table database.
Thank you for your help
Joe

Alexey admin 6/27/2006

Joe,
I see what you saying.
You can do this modifying your menu.asp file manually.
Run this query: > SELECT DISTINCT Make from ...

and display hyperlinks to the List page in the following form:

..._list.asp?action=SearchSearchField=Make&SearchOption=Equals&SearchFor=BMW



where Make is your table field name and BMW is the value selected from database.

S
Spitty author 6/27/2006

great! thank you so much, thats exactly what im looking for! however, where would i run the query in menu.asp?
Joe

Sergey Kornilov admin 6/27/2006

You just need to add a link to search results to menu.asp file.

<a href="TableName_list.asp?action=SearchSearchField=Make&SearchOption=Equals&SearchFor=BMW">Link</a>

S
Spitty author 6/28/2006

Hello thank you for all your help, it worked... in my test run with a standard MS Access DB. However, on changing my connection string manually for my ms sql db, all functions work (record display, add, edit etc) apart from the searches. I get the following error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
'ucase' is not a recognized function name.
/concept/output/_kdpProducts_list.asp, line 702
i looked up about in-sensitive case, but ive tried typing in exact case and i know there are several records with the word im typing in! Is is because sql server doesn't understand the function ucase, and there should be something else in its place?
the connection string i typed in manually is:
"PROVIDER=SQLOLEDB;DATA SOURCE=blabla.blabla.co.uk;UID=username;PWD=password;DATABASE=dbname"
(censored pass uid etc) The con string definately connects to the db as records are displayed...
Obviously im doing something wrong here, and im sorry to keep posting on such a mundain topic!
Joe

Sergey Kornilov admin 6/28/2006

Ucase is a MS Access function.
In SQL Server you need to use Upper function.

S
Spitty author 6/28/2006

Ucase is a MS Access function.

In SQL Server you need to use Upper function.


So do i just change Ucase to Upper in all asp files? Which i tried and developed errors? Or should i be directing the code to use ms sql functions instead of MS Access?
Im learning something new on every post!