public bool BatchUpdate(int id, string reason) { using (SqlConnection connection = new SqlConnection(DbHelperSQL.connectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction = connection.BeginTransaction(); command.Connection = connection; command.Transaction = transaction; try { string sql = string.Empty; if (!string.IsNullOrEmpty(reason)) { sql = "update news set ispass=3,datecheck=getdate(),FailReason='" + reason + "' where id=" + id; } else { sql = "update news set ispass=2,datecheck=getdate() where id=" + id; } command.ExecuteNonQuery(); transaction.Commit(); return true; } catch (Exception e) { transaction.Rollback(); return false; } } }