您的位置:首页 > 数据库

sqlserver 根据一个泛型id查询数据,批量删除数据

2013-04-07 15:51 543 查看
查询:

public static DataSet GetBlackList(List<long> idlist)

{

string sql = "select * from Apry ap where ap.id in (";

foreach (long id in idlist)

{

sql += id +",";

}

sql = sql.TrimEnd(','); //去掉结尾的逗号

sql += ")";

return DBHelper.SQLExecute(sql, null);

}

批量删除:

public static DataSet GetBlackList(List<long> idlist)

{

string sql = "delete Apry ap where ap.id in (";

foreach (long id in idlist)

{

sql += id +",";

}

sql = sql.TrimEnd(','); //去掉结尾的逗号

sql += ")";

return DBHelper.ExecuteNonQuery(sql, null);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐