1个回答
展开全部
你是要做in操作吧,似乎不能直接传参,试一下这种http://bbs.csdn.net/topics/340060124
或者这种
string query = "19,21,24";
string[] param = query.Split(',');
string temp = "";
for (int i = 0; i < param.Length; i++)
{
temp += "@param" + i.ToString() + ",";
}
string queryString = "SELECT id,gender,name FROM [user] Where id in(" + temp.Substring(0, temp.Length - 1) + ")";
SqlCommand cmd = new SqlCommand(queryString, conn);
for (int i = 0; i < param.Length; i++)
{
cmd.Parameters.Add("@param" + i.ToString(), SqlDbType.Int).Value = param[i];
}
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询