R
ric_deez
Hi there, I would like to create a simple search form to allow users to
search for a job number based on a number of parameters. I think I
understand how to use parameteres associated with Stored Procedures
with a data reader to add various parameters.
However, if I have a stored procedure such as
CREATE usp_SelectfromJobNumbers (@par1 datatype, @par2 datatype, @par3
datatype)
AS
SELECT FROM Jobs WHERE
PAR1 = @par1 AND
PAR2 = @par2 AND
PAR3 = @par3
I cannot just pass the one parameter to the procedure. The question
is then: how is it possible to create a stored procedure which can
accept any number of parameters an then smartly modify the query in the
store procedure with CASE statements or similar?
I don't really want to do this as in-line code as it easily becomes
unmaintainable and it is hard to add additional conditions. I was
thinking of passing a string array into the Stored Procedure and having
the stored procedure parse through the array, determine the parameters
and do the grunt of the work. The problem is that I haven't got a lot
of experience with these advanced stored procedures using CASE
statements and the like...
Any ideas would be greatly appreciated.
Regards,
Ric
search for a job number based on a number of parameters. I think I
understand how to use parameteres associated with Stored Procedures
with a data reader to add various parameters.
However, if I have a stored procedure such as
CREATE usp_SelectfromJobNumbers (@par1 datatype, @par2 datatype, @par3
datatype)
AS
SELECT FROM Jobs WHERE
PAR1 = @par1 AND
PAR2 = @par2 AND
PAR3 = @par3
I cannot just pass the one parameter to the procedure. The question
is then: how is it possible to create a stored procedure which can
accept any number of parameters an then smartly modify the query in the
store procedure with CASE statements or similar?
I don't really want to do this as in-line code as it easily becomes
unmaintainable and it is hard to add additional conditions. I was
thinking of passing a string array into the Stored Procedure and having
the stored procedure parse through the array, determine the parameters
and do the grunt of the work. The problem is that I haven't got a lot
of experience with these advanced stored procedures using CASE
statements and the like...
Any ideas would be greatly appreciated.
Regards,
Ric