SqlServer2008与asp.net使用中的一些问题
永远的小鱼 2010-07-12 01:34:26 废话不多说 代码:
int[] CountID = {5,7,8,9,10};
1.
SqlCommand comm = new SqlCommand("select * from xxbb where OrderID in {@Value}",conn); //OrderID 为BigInt类型
comm.Parameters.Add(new SqlParameter("@Value", SqlDbType.?????)); // 这里的类型怎么写?
comm.Parameters["@Value"].Value = CountID;
comm.ExecuteReader(); //报错了
2.
把 int[] CountID = {5,7,8,9,10}; 改成 String CountID = "5,7,8,9,10";
SqlCommand comm = new SqlCommand("select * from xxbb where OrderID in {@Value}",conn); //OrderID 为BigInt类型
comm.Parameters.Add(new SqlParameter("@Value", SqlDbType.VarChar)); // 这里的类型怎么写?
comm.Parameters["@Value"].Value = CountID;
comm.ExecuteReader(); //报错! 类型转失败 无法将String 转换为int