asp.net如何传数组

来源:百度知道 编辑:UC知道 时间:2024/06/24 18:18:48
int[] a={1,2,3,4,5,6};
要查询的语句为
select * from productclass where productclass_ID in (1,2,3,4,5,6);
怎么把a传给要查询的方法呢

我说楼主你怎么这么一根筋,不会把数组转化成字符串啊
string str="";
for(int i=0;i<a.length;i++)
{
str+=a[i].tostring()+",";
}

将数组拼成字符串传入数据库,然后再存储过程里与查询语句进行拼接。

将a 分割成一个字符串就行了
string aa="";
for(int i=0;i<a.length;i++)
{
aa=aa+","+a[i];
}
select * from productclass where productclass_ID in (aa.Substring(1));