Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 283581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:23:08+00:00 2026-05-12T05:23:08+00:00

Suppose I have a search screen that is intended for looking up items. There

  • 0

Suppose I have a search screen that is intended for looking up items. There are various optional search options on the screen that will cause the SQL query statement to vary.

Here are some example searches:

  1. Description search
  2. Description search + item supplier id
  3. Description search + item supplier id + item hierarchy level 1 id
  4. Description search + item supplier id + item hierarchy level 1 id + level 2 id
  5. item hierarchy level 1 id + level 2 id (no description, no item supplier id)

…you get the idea. There are quite a number of possible combinations. I was hoping to use parameterized queries for the performance benefits and such (plus I’m using them for the rest of the queries throughout the program).

Is there a way to do this or am I forced to either create each possible query and matching SQLiteCommand object or build the query string dynamically with a StringBuilder based on the options selected?

I’m using using the SQLite.NET data provider with C# 3.0 (on the 3.5 compact framework).


UPDATE

Based on some of the suggestions with null default values for the parameters and using (@param isnull or column = @param), I think I should be able to get this to work. I’ll keep you posted.

NOTE: I am avoiding using stored procedures because the rest of the code uses parameterized queries instead of stored procedures. I’d like to keep everything consistent for the sanity of future maintenance programmers. It shouldn’t make too much of a difference anyway.


UPDATE 2

This worked great on a desktop system (which is where I did my initial testing for the queries). However, it was very slow on the Windows CE Device I was using. Unusably slow. All the same, I can definitely use this in the future and it’s very handy. Just not when running queries on a mobile device.

Thanks

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:23:08+00:00Added an answer on May 12, 2026 at 5:23 am

    From the stored procedure side you can default values to null then build your where clause to accommodate this null value.

    ALTER Procedure FooProcedure 
        @SupplierID INT = NULL,
        @LevelOne INT = NULL 
    AS
    BEGIN
    
        SELECT SupplierID, LevelOne 
          FROM FooTable
         WHERE @SupplierID IS NULL OR SupplierID = @SupplierID
           AND @LevelOne IS NULL OR LevelOne = @LevelOne 
    
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the SQL Full-Text Search and have a stored proceedure that uses the
Are hashtables always faster than trees? Though Hashtables have O(1) search complexity but suppose
Suppose I was given a URL. It might already have GET parameters (e.g. http://example.com/search?q=question
I have a PHP script that's supposed to take in a URL and search
Suppose you have a subsystem that does some kind of work. It could be
Suppose I have an autocomplete control for search purpose in my wp7 app, and
Suppose I have a massive table called inactiveUsers and a search form. I want
Suppose I have a table called 'test', into which there are three columns named
suppose I have www.usa.com as main site. I will create www.utah.com..www.indiana.com...etc on same dedicated
I'm new to free-text search, so pardon the newbie question. Suppose I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.