SQL WHERE AND OR Syntax for Custom Report.

  • I need an example on how to use SQL 2000 syntax to build a user-friendly SQL WHERE syntax for building custom reports in .NET......

    I have the following columns that need to mix-n-match (within reason). They inturn 'load' comboboxes on a Win-Form, not ASPX.

    Some of the columns are: TimeBegin, TimeEnd, FName, MName, LName, Age, Height, Weight, State, City, Zip, etc.........

    So a typical user might search BETWEEN 'TimeBegin' AND 'TimeEnd' WHERE 'FName' AND/OR 'Age' AND/OR ...

    They might skip the 'Time' altogether and search by any combination of the other columns....

    I've attempted this in .NET C# and found using 'IF' statements much too complicated. I'm hoping SQL will not only simply the task, but also add better performance. 

  • Your basically trying to build a dynamic search.

    where some of the fields in the where clause are optional.

    this will help you

    http://www.sommarskog.se/dyn-search.html

    Or you can performan parameterized queries from within .Net where you use embedded sql, and build your query in your application.

  • Another option is to create a stored procedure in SQL that will bring back your complete recordset. Bring in the recordset through your application, and then use the rowfilter property to filter the dataset according to the user's options.

     

    HTH,

    Sandi

  • Most Excellent, Thank You...............

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply