public bool ExecuteQueries() { ////Execute the queries foreach (DatabaseQuery q in Queries) { if (q.Message == Messages.DropDatabase || q.Message == Messages.CreateDatabase || q.Message == Messages.EnableDBCT || q.Message == Messages.DisableDBCT || q.Message == Messages.AlterDatabase) { OnUpgrading(q); string error = ""; int queryResult = DbInfo.ExecuteNonQuery(q.SqlStatement, true, out error); if (queryResult > 0 || queryResult == -1) { q.Result = 1; } else { q.Result = -1; q.ErrorMessage = error; } } } //// Execute all sql statements NOT related to create, drop or alter database etc... DbInfo.BeginTransaction(false); foreach (DatabaseQuery q in Queries) { if (q.Message != Messages.DropDatabase && q.Message != Messages.CreateDatabase && q.Message != Messages.EnableDBCT && q.Message != Messages.DisableDBCT && q.Message != Messages.AlterDatabase) { OnUpgrading(q); string error = ""; int queryResult = DbInfo.ExecuteNonQuery(q.SqlStatement, out error); if (queryResult > 0 || queryResult == -1) { q.Result = 1; } else { q.Result = -1; q.ErrorMessage = error; } } } //// Rollback transaction if execution of any sql statement failed on the database. Otherwise commit transaction if (Queries.HasErrors) { DbInfo.RollBackTransaction(); return(false); } else { DbInfo.CommitTransaction(); return(true); } }