我正在为学校做一个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
答案 0 :(得分:0)
如果您使用Entity Framework
,则可以保留LINQ
样式,当您对实体对象进行更改时,您只需在.Save
上调用Enitity Container
即可。