Groups | Blog | Home
all groups > asp.net webcontrols > june 2004 >

asp.net webcontrols : listbox and sql stored procedure


Scott G.
6/30/2004 3:28:50 PM
How about something like:

CREATE PROCEDURE pdTableName @IDs VARCHAR(4000)
AS
EXEC ('DELETE FROM TableName WHERE ID IN (' + @IDs + ')')
RETURN 0

Of course, you'd have to make sure that @IDs has all of the single =
quotes and commas, or you could add that to your stored procedure.

Scott
[quoted text, click to view]
write a routine to concatenate the selected IDs into a comma seperated
string then pass this as a single varchar parameter in the proc

create procedure pdTableName @IDs varchar(4000) AS

DELETE FROM TableName WHERE ID in (@IDs)


John
6/30/2004 4:32:22 PM
Hi,
First of all sorry for my not perfect english.

I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select 7 items in listbox, I have to take value from
items and pass it to stored procedure to delete 7 rolls in my table. Thats
simple, but what if user select 3 or 30 items in listbox? The problem is
that I dont know the number of the parameters, and how to pass them. can I
use array or is there some different solution?

Of course I can take the collection of items and for every item, I can
call stored procedure, but this is no good in performance reason.
Please help me

Josh
6/30/2004 5:40:51 PM
write a routine to concatenate the selected IDs into a comma seperated
string then pass this as a single varchar parameter in the proc

create procedure pdTableName @IDs varchar(4000) AS

DELETE FROM TableName WHERE ID in (@IDs)


something like that anyway...

AddThis Social Bookmark Button