By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,571 Members | 2,639 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,571 IT Pros & Developers. It's quick & easy.

Define 8 parameters in a Object's function ~~

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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> bl
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 discussion thread is closed

Replies have been disabled for this discussion.