public NhlStatsSet.scheduleDataTable GetScheduleByDate(int seasonId, DateTime startDate, DateTime endDate) { string startDateString = startDate.ToString("s", System.Globalization.CultureInfo.InvariantCulture); string endDateString = endDate.ToString("s", System.Globalization.CultureInfo.InvariantCulture); NhlStatsSet.scheduleDataTable table = new NhlStatsSet.scheduleDataTable(); SQLiteCommand command = new SQLiteCommand(); command.Connection = connection; command.CommandText = String.Format( "SELECT * FROM schedule WHERE Season_ID = {0} " + "AND datetime(Date) >= datetime('{1}') AND datetime(Date) <= datetime('{2}')", seasonId, startDateString, endDateString); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(table); return table; }
public NhlStatsSet.scheduleDataTable GetScheduleForTeams(String teamA, String teamB, int seasonId, int gameCount, bool past) { string startDateString = DateTime.Now.ToString("s", System.Globalization.CultureInfo.InvariantCulture); NhlStatsSet.scheduleDataTable table = new NhlStatsSet.scheduleDataTable(); SQLiteCommand command = new SQLiteCommand(); command.Connection = connection; command.CommandText = String.Format( "SELECT * FROM schedule WHERE Season_ID = {0} AND ((HomeTeam = '{1}' AND AwayTeam = '{2}') OR (HomeTeam = '{2}' AND AwayTeam = '{1}'))" + "AND datetime(Date) {5} datetime('{3}') LIMIT {4}", seasonId, teamA, teamB, startDateString, gameCount, past ? "<" : ">=" ); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(table); return table; }