Pass checkbox list multiple selected value to stored procedure through one parameter

i have checkbox list to select multiple value ,now i want to pass this multiple selected value to my stored procedure using one parameter

insert into tblAccessRights (roleid,customerid,SubcustomerId)
values(@_roleid,@CustomerId,@SubcustomerId,)

in above query @SubcustomerId is parameter which will hold the multiple selected value from checkboxlist so,now the entry should be like as follow

roleid customerid subcustomerid
 1        2           6
 1        2           7
 1        2           8

this subcustomerid is multiple selected value from check box ,how can i achieve this with one parameter,if any other way to do this then please reply

Can it be done with dynamic query if i take checkboxlist value as comma separated string and accordingly pass it to dynamic insert query...

Answers


i got solution for this finally,!!!! im giving my solution for refrence

i took the check box list in string as comma separated value and pass it to stored procedure then i use dynamic query to insert this value as follow:

 
create table tblrmp
 ( id int identity (1,1),
 name varchar(20), 
subcat varchar(20) ) 

declare @S varchar(20) set @S = '1,2,3,4,5' declare @sql varchar(max) while len(@S) > 0 begin print left(@S, charindex(',', @S+',')-1) set @sql='insert into tblrmp values(''abc'','+left(@S, charindex(',', @S+',')-1)+')' exec(@sql) set @S = stuff(@S, 1, charindex(',', @S+','), '') end

output: id name subcat 1 abc 1 2 abc 2 3 abc 3 4 abc 4 5 abc 5


Need Your Help

Cannot format date in jqGrid

javascript c# jquery jqgrid

here is my situation. From the server (written in C#), I pass a DateTime object to client using JSON, then I try to display it using jqGrid. However, the date keep displaying like /Date(1430413200000+

Get mutiple multiple rows value base on array id IN CAKE PHP

php cakephp cakephp-2.0 cakephp-1.3

i want to get multiple rows value base on multiple id value and i m getting id in array.