/// <summary> /// This will execute the sql statements. /// </summary> /// <param name="tableStatements"></param> /// <param name="dbName"></param> private static void ExecuteStatements(string[] tableStatements, InstallerConfig config) { if (tableStatements.Length > 0) { using (SqlConnection conn = new SqlConnection()) { IConnectionStringComponent component = new ConnectionStringComponent(config); conn.ConnectionString = component.GetConnString(); conn.Open(); using (SqlCommand command = new SqlCommand(string.Empty, conn)) { foreach (string statement in tableStatements) { command.CommandText = statement; command.ExecuteNonQuery(); } } } } }
/// <summary> /// This will execute the sql statements. /// </summary> /// <param name="tableStatements"></param> /// <param name="dbName"></param> private void ExecuteStatements(string[] tableStatements, InstallerConfig config) { if (tableStatements.Length > 0) { using (SqlConnection conn = new SqlConnection()) { IConnectionStringComponent component = new ConnectionStringComponent(config); conn.ConnectionString = component.GetConnString(); conn.Open(); using (SqlCommand command = new SqlCommand(string.Empty, conn)) { foreach (string statement in tableStatements) { command.CommandText = statement; command.ExecuteNonQuery(); } } } } }
/// <summary> /// This will execute the sql statements. /// </summary> /// <param name="tableStatements"></param> /// <param name="dbName"></param> private static void ExecuteStatements(string[] tableStatements, InstallerConfig config) { if (tableStatements.Length > 0) { using (SqlConnection conn = new SqlConnection()) { // Make sure we're not returning the EntityFramework connection string. config.Database.EntityFrameworkEntitiesName = ""; IConnectionStringComponent component = new ConnectionStringComponent(config); conn.ConnectionString = component.GetConnString(); conn.Open(); using (SqlCommand command = new SqlCommand(string.Empty, conn)) { foreach (string statement in tableStatements) { command.CommandText = statement; command.ExecuteNonQuery(); } } } } }