Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

search option

Posted on 2004-09-03
3
Medium Priority
?
171 Views
Last Modified: 2010-04-23

hi

        I have a  form with 5 controls(all fields are not mandatory). all the fields are in one table. I have to perform search based on values entered by the user and display it in datagrid

anyone tell how to write a store procedure for implemening this.

thanks
sandeep
0
Comment
Question by:sandeep437
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
asherratt earned 500 total points
ID: 11977267
If I am understanding correctly you are looking to write a stored procedure to search a table based on the values that the user enters into the 5 controls on the form...

Your stored procedure should have 5 parameters (1 for each value) for each value that is optional you declare that the default for the value is NULL. Then where you do the search you select from the table where the values match the ones given by the user, unless the value is NULL.  The procedure would look something like this (I'm only using 2 parameters but you get the idea).

CREATE PROC myProc
  @param1 paramtype,
  @param2 paramtype = NULL
AS
  Select * from myTable where field1=@param1 and ((param2 is NULL) or (field2=@param2))

The results should be what you are looking for.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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