Solved

search option

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now