I have Drop Down List with check box in my asp.net page.
in that page i am going to checked multiple / single / all values.
now i want to pass all selected values from dropdownlist to sql server 2005 stored procedure as parameters.
i want to Pass the array of selected values as a string, each array item separated by a ‘,’
And in stored procedure i want to retrieve each values one by one.
(using split function or any better option ? )
and i want to process insert query on each selected parameters.
any help please.
I have tried This Stored Procedure.
CREATE PROCEDURE [dbo].[TEST_LIST]
@ID_LIST VARCHAR(200)
AS
DECLARE @pos int,
@nextpos int,
@valuelen int
SELECT @pos = 0, @nextpos = 1
WHILE @nextpos > 0
BEGIN
SELECT @nextpos = charindex(‘,’, @ID_LIST, @pos + 1)
SELECT @valuelen = CASE WHEN @nextpos > 0
THEN @nextpos
ELSE len(@ID_LIST) + 1
END – @pos – 1
INSERT INTO TABLE
(ID)
VALUES (convert(int, substring(@ID_LIST, @pos + 1, @valuelen)))
SELECT @pos = @nextpos
END
RETURN
END
BUT IS THIS CORRECT ??
I GOT ERROR.
please note this > one by one i want to retrieve parameters and at each time i have insert query.
AS ANSWER OF MY QUESTION,
YOU PLEASE CHANGE YOUR STORED PROCEDURE
AS SHOWN BELOW.
AS
BEGIN
END
THANKS TO ALL.