473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Define 8 parameters in a Object's function ~~

I got a gobal object which has search function . I will pass 8 paramemter in
that object,
And In that search function, it will call 'stored procedure' with filling 8
parameters.
in that stored procedure, there is select case@ statment.

My question is, will the above design too BAD ??? or Should I changed the
design (not using the store procedure
with parameters, , BUT use commandtext (e.g select xx from myTable where
xxxxx) instead ??>

Thanks a lot.
Nov 21 '05 #1
2 1006
Hi,

I wouldn't do it that way. In your stored procedure, where you declare your
inputs, set them all to NULL as default. Then only pass in the parameters
that you need, so if you pass in only two, say @FirstName and @LastName then
all the rest will be null. Then write your stored procedure like this:

Select
*
From
People
Where
((FirstName = @FirstName) OR (@FirstName IS NULL)) AND
((LastName = @LastName) OR (@LastName IS NULL)) AND
((Age = @Age) OR (Age IS NULL)) AND
Nov 21 '05 #2
Yeap, your point is great' Doing it this way you won't have to create a huge
web of conditionals to try
to generate a valid query. ' I will try your codes,
Thanks
"Ken Dopierala Jr." <kd*********@wi.rr.com> ¦b¶l¥ó
news:eZ**************@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
Hi,

I wouldn't do it that way. In your stored procedure, where you declare your inputs, set them all to NULL as default. Then only pass in the parameters
that you need, so if you pass in only two, say @FirstName and @LastName then all the rest will be null. Then write your stored procedure like this:

Select
*
From
People
Where
((FirstName = @FirstName) OR (@FirstName IS NULL)) AND
((LastName = @LastName) OR (@LastName IS NULL)) AND
((Age = @Age) OR (Age IS NULL)) AND
.
.
.
Order By
FirstName

I'm just guessing this is what you want to do, if it isn't let me know.
Doing it this way you won't have to create a huge web of conditionals to try to generate a valid query. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:Ow*************@tk2msftngp13.phx.gbl...
I got a gobal object which has search function . I will pass 8 paramemter
in
that object,
And In that search function, it will call 'stored procedure' with
filling 8
parameters.
in that stored procedure, there is select case@ statment.

My question is, will the above design too BAD ??? or Should I changed

the design (not using the store procedure
with parameters, , BUT use commandtext (e.g select xx from myTable where
xxxxx) instead ??>

Thanks a lot.


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Diez B. Roggisch | last post by:
Hi, I've got code objects that are created from strings at runtime that look like this: def p_op1(_, args): _.add_dependency('p_op1') As you migth guess, p_op1 is supposed to become an...
6
by: simon | last post by:
Always when I need data reader in my programs, I simply have functions, which creates it for me: Dim rdr As SqlDataReader dim sql as string sql="myStoredProcedure" rdr =...
10
by: Felix Kater | last post by:
Hi, is it possible to define a function in a way that when calling it I can insert as many arguments as I want? (I would neither like to define a function with 50 default arguments nor prepare a...
0
by: Paul Allan | last post by:
I am new to ASP.net (intermediate ASP developer). I am developing a ASP.net web application and I am having some difficulty calling and passing parameters to a function that is declared in my...
1
by: Kalim Julia | last post by:
does Anybody know how to define a multiple set of parameter (like OleDbCommand's parameter - there are 4 sets of parameter)
4
by: astri | last post by:
#include "Unit1.h" #include "math.h" #include "fixed_math.hpp" #include "algorithm.h" #define MBIT 0x4000 #define CBIT 16 long constbl; void __fastcall TForm1::Button1Click(TObject...
7
by: =?gb2312?B?wfXquw==?= | last post by:
Hi folks, I am running into with such a question when I tried to declare and define a friend template function in a template class, here is the code snippet: #include <iostream> using...
11
by: Mtr | last post by:
this results in "unexpected T_OBJECT_OPERATOR" Parse error How do I do this, without needing two lines such as $o = new Object(); $o->function(); Also, what does "unexpected...
0
by: John O'Hagan | last post by:
On Tue Sep 30 11:32:41 CEST 2008, Steven D'Aprano Thanks, both to you and Bruno for pointing this out, I'll certainly be using it in future.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.