protected int insert(SqlDataReader reader, LRTKey lrtKey, Power power) { SqlCommand modifyCmd = new SqlCommand(@"UPDATE dbo.history SET PrevAvgStrength=@PrevAvgStrength WHERE ID=@ID", Connection); modifyCmd.Parameters.AddWithValue("@PrevAvgStrength", power.PrevAvgStrength); modifyCmd.Parameters.AddWithValue("@ID", reader[0]); return modifyCmd.ExecuteNonQuery(); }
public static Dictionary<LRTKey, Power> getHistoryDict(SqlConnection connection) { string q = "SELECT * FROM dbo.history WHERE grStrength IS NOT NULL ORDER BY Country,League,Season,Team,Round"; Dictionary<LRTKey, Power> dict = new Dictionary<LRTKey, Power>(); LRTKey lrtKey = new LRTKey(); using (SqlDataReader reader = new SqlCommand(q, connection).ExecuteReader()) { while (reader.Read()) { lrtKey.Country = reader["Country"].ToString(); lrtKey.League = reader["League"].ToString(); lrtKey.OtherTeam = reader["OtherTeam"].ToString(); lrtKey.Round = (byte)reader["Round"]; lrtKey.Season = reader["Season"].ToString(); lrtKey.Team = reader["Team"].ToString(); dict[lrtKey] = new Power(reader); } } return dict; }