コード例 #1
0
        /// <summary>
        /// FIll a list of classes with all of the leagues that a team plays in
        /// </summary>
        /// <param name="TeamID">The team who's leagues are being searched.</param>
        /// <returns>A list of all of the leagues that the team plays in</returns>
        public static List <Classes.League> FillFromTeam(int TeamID)
        {
            List <Classes.League> LeagueList = new List <Classes.League>();

            try
            {
                OleDbCommand command = new OleDbCommand("SELECT League.LeagueID, League.LeagueName, League.Capacity, League.Sponsor FROM League INNER JOIN TeamLeague ON League.LeagueID = TeamLeague.LeagueID WHERE(((TeamLeague.TeamID) = 1)); ", Database.DatabaseConnection.DBConnection);
                command.Parameters.Add(new OleDbParameter("@varteam", TeamID));
                OleDbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Classes.League League = new Classes.League();
                    League.LeagueId   = Int32.Parse(reader[0].ToString());
                    League.LeagueName = reader[1].ToString();
                    League.Capacity   = Int32.Parse(reader[2].ToString());
                    League.Sponsor    = reader[3].ToString();
                    LeagueList.Add(League);
                }
            }
            catch (OleDbException exception)
            {
                MessageBox.Show(exception.Message, "OleDb Exception");
            }
            return(LeagueList);
        }
コード例 #2
0
        /// <summary>
        /// FIll a list of classes with all of the leagues
        /// </summary>
        /// <returns>A list of all of the leagues</returns>
        public static List <Classes.League> Fill()
        {
            List <Classes.League> LeagueList = new List <Classes.League>();

            try
            {
                OleDbCommand    command = new OleDbCommand("Select * from League;", Database.DatabaseConnection.DBConnection);
                OleDbDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    Classes.League League = new Classes.League();
                    League.LeagueId   = Int32.Parse(reader[0].ToString());
                    League.LeagueName = reader[1].ToString();
                    League.Capacity   = Int32.Parse(reader[2].ToString());
                    League.Sponsor    = reader[3].ToString();
                    LeagueList.Add(League);
                }
            }
            catch (OleDbException exception)
            {
                MessageBox.Show(exception.Message, "OleDb Exception");
            }
            return(LeagueList);
        }