コード例 #1
0
ファイル: Hscore.cs プロジェクト: gregtuck/SecurityQuiz
        //get the top 5 high scores from database
        public void fetchHighScores()
        {
            SqlConnection con = connect.connection;

            try
            {
                con.Open();
                SqlCommand    cmd = new SqlCommand("SELECT TOP 5 playername, score FROM GAMESEC_APP.HIGHSCORES ORDER BY score DESC", con);
                SqlDataReader sdl = cmd.ExecuteReader();

                while (sdl.Read())
                {
                    Hscore player = new Hscore();
                    player.rankedPlayer = sdl[0].ToString();
                    player.rankedScore  = (int)sdl[1];

                    highScores.Add(player);
                }
                highscoreArr = highScores.ToArray();
            }
            catch (Exception)
            {
                System.Windows.Forms.MessageBox.Show("Could not get high scores");
            }
        }