public void updateSessions() { DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions); foreach (DataRow dRow in table.Rows) { List <string> removeColumns = null; int roundNumber = (int)dRow["Round_Number"]; int numberOfSessions = (int)dRow["Number_Of_Sessions"]; if (numberOfSessions > m_oldNumberOfSessions[roundNumber]) { List <DatabaseField> fields = new List <DatabaseField>(); for (int i = m_oldNumberOfSessions[roundNumber] + 1; i <= numberOfSessions; ++i) { fields.Add(new DatabaseField("Session_" + i + "_Score", "NUMBER")); } AccessDatabaseUtilities.addColumn(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber, fields); } else if (m_oldNumberOfSessions[roundNumber] > numberOfSessions) { removeColumns = new List <string>(); List <DatabaseField> fields = new List <DatabaseField>(); for (int i = numberOfSessions + 1; i <= m_oldNumberOfSessions[roundNumber]; ++i) { fields.Add(new DatabaseField("Session_" + i + "_Score", "NUMBER")); removeColumns.Add("Session_" + i + "_Score"); } AccessDatabaseUtilities.dropColumn(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber, fields); } m_oldNumberOfSessions[roundNumber] = numberOfSessions; AccessDatabaseUtilities.loadDatabaseToTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber, "", removeColumns); } AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutSessions); }