62,046
社区成员
发帖
与我相关
我的任务
分享
public void Remove(ArrayList array)
{
string connectionString = ConfigurationManager.ConnectionStrings["SQLConnString1"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlTransaction tran = conn.BeginTransaction();
try
{
for (int i = 0; i < array.Count; i++)
{
SqlCommand cmd = new SqlCommand("", conn, tran);
cmd.CommandText = " UPDATE [D_TB_Device_Apply] SET flag = 1 WHERE Item_apply_Id = '" + array[i] + "'";
if (!(cmd.ExecuteNonQuery() > 0))
{
throw new Exception(array[i].ToString() + "删除失败!");
}
}
tran.Commit();
}
catch (Exception exp)
{
tran.Rollback();
throw exp;
}
finally
{
conn.Close();
}
}