Solved

search option

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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

622 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