日期:2014-05-18 浏览次数:20486 次
string whereClause = string.Empty;
foreach (遍历CheckBoxList)
{
if (选中)
{
if (whereClause == string.Empty)
whereClause += "'" + 取值 + "'";
else
whereClause += ",'" + 取值 + "'";
}
}
if (whereClause != string.Empty)
{
SqlConnection cn = new SqlConnection(...);
string strSQL = "delete from mytable where id in (" + whereClause + ")";
SqlCommand cmd = new SqlCommand(strSQL, cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
------解决方案--------------------