Solved

search option

Posted on 2004-09-03
3
168 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
3 Comments
 
LVL 1

Accepted Solution

by:
asherratt earned 125 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
location of a form 2 32
vb.net Configuration, settings file location? 8 41
Asp.Net Session Question 2 33
visual studio vb.net windows onkeyup 2 25
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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