A logic which I am doing in a complex way.
I just need to execute this query in a stored procedure:
select Sizes, SUM(Quantity)
from tbl_SizeBreakup
where (Brand=@brand)
and (Combo in ('1','2')) ...
The combo I must pass in SQL parameter using in C# is
DataSet dt = new DataSet();
cmd = new SqlCommand();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "sp_Accessories";
cmd.Connection = con;
cmd.Parameters.AddRange(
new SqlParameter[] {
new SqlParameter("@Mode",mode),
new SqlParameter("@Combo",combo),
}}
So if I pass 1 parameter, working as expected. The combo which I should pass is a string[]
(string array). The array length can be anything depends on the user selecting in UI.
My question is, how to pass string[]
to new SqlParameter("@Combo",combo)
?
My stored procedure..
ALTER proc [dbo].[sp_Accessories]
(
@Mode varchar(50)=null,
@id int=null,
@brand varchar(50)=null,
@department varchar(MAX)=null,
@season varchar(50)=null,
@groupname varchar(MAX)=null,
@styles varchar(50)=null,
@combo varchar(50)=null,
@combo_color nvarchar(max)=null,
)
as
if @Mode='getsizewise'
begin
select Sizes,SUM(Quantity) from tbl_SizeBreakup where (Brand=@brand) and (Department=@department) and (Season=@season) and (Group_Name=@groupname) and (Style=@styles)
and (Combo_Color=@color) and (Total_Add_Qty='Total Quantity') Group By Sizes
end