コード例 #1
0
ファイル: ViewResults.aspx.cs プロジェクト: s00141954/WebProg
        // Get the player names for display in GridView
        private List<Player> GetPlayerNames()
        {
            //command.Connection = connection;
            //command.CommandType = CommandType.StoredProcedure;
            //command.CommandText = "GetTeamPlayers";

            connection.Open();

            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                Player player = new Player()
                {
                    PlayerId = Convert.ToInt32(reader["PlayerId"]),
                    PlayerName = reader["PlayerName"].ToString(),
                    TeamId = Convert.ToInt32(reader["TeamId"])
                };
                players.Add(player);
            }
            reader.Close();
            connection.Close();

            return players;
        }
コード例 #2
0
ファイル: Home.aspx.cs プロジェクト: s00141954/WebProg
        private List<Player> GetTeamPlayers(int teamId)
        {
            List<Player> players = new List<Player>();

            connection.Open();

            command.Connection = connection;
            command.Parameters.Clear();
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@TeamId", teamId);
            command.CommandText = "GetTeamPlayers";

            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                Player player = new Player()
                {
                    PlayerId = Convert.ToInt32(reader["PlayerId"]),
                    PlayerName = reader["PlayerName"].ToString()
                };
                players.Add(player);
            }
            reader.Close();
            connection.Close();

            return players;
        }