我正在为学校开发一个 VB 项目。这是一个蛇游戏,我将高分存储在数据库中。我需要知道如何从数据集中插入和删除记录,以便摆脱旧的低分并插入新的高分。我们在课堂上只简单地介绍了 LINQ,所以我一无所知。
这就是我到目前为止所拥有的,并且一切正常。
Private Sub HighScores_Load(sender As System.Object, e As System.EventArgs)
Handles MyBase.Load
'See if player score is higher than the low score, and if so, add player name and score to database
Me.HighscoresTableAdapter.Fill(Me.VbprojectDataSet.highscores)
Dim lowScore = Aggregate scores In VbprojectDataSet.highscores
Select scores.score
Into Min()
If GridForm.player.score > lowScore Then
Dim lowScoreRow = From scores In VbprojectDataSet.highscores
Where scores.score = lowScore
Select scores
GridForm.player.name = InputBox("You got a new high score! What is your name?", "SnakE")
End If
End Sub