public void ExecuteNonQuery(ConnectionSettings settings, string sql, bool includeDatabaseName = false)
{
string connectionString = _connectionStringGenerator.GetConnectionString(settings, includeDatabaseName);
using (var connection = new SqlConnection(connectionString))
{
connection.Open();
using (var command = new SqlCommand())
{
command.Connection = connection;
command.CommandTimeout = 0;
var scripts = SplitSqlStatements(sql);
foreach (var splitScript in scripts)
{
command.CommandText = splitScript;
try
{
command.ExecuteNonQuery();
}
catch (Exception ex)
{
ex.Data.Add("Custom", "Erroring script was not run in a transaction and may be partially committed.");
throw ex;
}
}
}
}
}