public SqlBatchExecution ExecuteSqlBatch(ISqlBatch sqlBatch) { SqlBatchExecution execution = new SqlBatchExecution(); using (SqlConnection dbConnection = new SqlConnection(_connectionString)) using (SqlCommand dbSqlCommand = new SqlCommand(sqlBatch.Sql, dbConnection)) { dbSqlCommand.CommandType = CommandType.Text; dbConnection.Open(); try { dbSqlCommand.ExecuteNonQuery(); } catch (SqlException ex) { execution.Exception = ex; } dbConnection.Close(); } sqlBatch.Executions.Add(execution); return(execution); }
public SqlBatchExecution ExecuteSqlBatch(ISqlBatch sqlBatch) { SqlBatchExecution execution = new SqlBatchExecution(); using (SqlConnection dbConnection = new SqlConnection(_connectionString)) using (SqlCommand dbSqlCommand = new SqlCommand(sqlBatch.Sql, dbConnection)) { dbSqlCommand.CommandType = CommandType.Text; dbConnection.Open(); try { dbSqlCommand.ExecuteNonQuery(); } catch (SqlException ex) { execution.Exception = ex; } dbConnection.Close(); } sqlBatch.Executions.Add(execution); return execution; }