Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
        }