Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Display all when first selection is made on drop down menu

Posted on 2013-12-14
5
Medium Priority
?
286 Views
Last Modified: 2013-12-19
I am using SQL, ASP classic and VBscript on my results page.

On the search page I have a drop down menu listing a list of clients, it displays the name of the client and passes on the ID of the client to page # 2

The query on page # 2 filters out using the ID.

I am using Dreamweaver to create my recordsets.

The sql reads:  Select * from table where  b.userid = MMColParam11

The first item of the list of clients says "All clients", which is manually entered, the rest come from a recordset and all have names and ID's.

When I filter text fields I can use the '%' to get all records for "All" or when no selection is made, in this case they are integer numbers, I get an error if I use % ... is there a way alternative to pass a value that will return ALL records like when comparing a text ?
0
Comment
Question by:Aleks
  • 3
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 39719207
Hi,

I think you have either to change the query in a way to use something like
Select * from table where  b.userid > MMColParam11

Open in new window

passing the value 0 to MMColParam11
OR
you change the query like
Select * from table where  b.userid = MMColParam11 OR 1=1

Open in new window

adding a condition which is always true.

HTH
Rainer
0
 

Author Comment

by:Aleks
ID: 39719237
I pass 0 then great, all come up, but if I pass a value like 120, then instead of just getting 120, I get 120 and any other ID above 120 correct ?... that won't work.

It was to be the ID that is selected and if none then ALL.

I can pass '0' and if that is the case I would need to return all ... can this be done as a condition ?

if MMColParam11 = 0 then (no requirement to match b.userid),
if MMColParam11 <>) then 'WHERE b.userid = MMColParam11

Just an idea but I am not sure if that can be done in a query.
0
 
LVL 44

Assisted Solution

by:Rainer Jeschor
Rainer Jeschor earned 2000 total points
ID: 39719251
Hi,
I meant that in your code where you create your query, you use something like
yourSelectQuery = "Select * from table where  b.userid"
If MMColParam11 = 0 Then
  yourSelectQuery = yourSelectQuery  & ">0"
Else
  yourSelectQuery = yourSelectQuery  & "=" & MMColParam11
End If

Open in new window


This will return everything if the value is 0 OR it returns the provided userid

HTH
Rainer
0
 

Author Comment

by:Aleks
ID: 39719263
1=1 won't work, if I make a selection and an ID is passed it displays ALL results. This should ONLY happen if MMColParam11 is '0', which is the default value when nothing is passed
0
 

Author Closing Comment

by:Aleks
ID: 39729794
:)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question