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
Solved

search option

Posted on 2004-09-03
3
167 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB: Convert 2 dates to specific format 24 52
VB.net and sql server 4 45
get combo value in class 5 14
Error message when using PrintSocket.Send 7 18
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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