[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

where clause select all if empty

using asp.net 2.0 .... What i would like to do is create a search to my current page where if the person enters the search and it comes up empty all records will show instead of a blank table.

Is there something i can put in as the default value of the parameters property to make the default show all records or any other suggestions?  I am using an access database.
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
where field = <search_value> OR <search_value> = '' or <search_value> IS NULL
Generally you can do a "LIKE" search.

If your sql is something like this:

SELECT * FROM table WHERE UserName = (Parameter)

Then change it to be like this:

SELECT * FROM table WHERE Username LIKE (Parameter) & "*"

This way if the parameter is blank you'll be selecting where LIKE * which will give you all records.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now