SqlConnection conn = new SqlConnection(bd.ConectionString);
conn.Open();
SqlTransaction trans = conn.BeginTransaction();
try
{
SqlHelper.ExecuteNonQuery(trans, CommandType.Text, consulta);
trans.Commit();
}
catch
{
// Restore the database state if there was an error.
trans.Rollback();
}
finally
{
conn.Close();
} |