对数据库的更改无法更新 - visual basic

时间:2017-05-09 04:12:24

标签: sql database vb.net ms-access

我在使用我的二十一点游戏获得我的分数以更新到我的记分板数据库中的分数表时遇到问题。当我单击保存分数时,它会将当前用户名和分数添加到ScoresDataGridView中,但是当我关闭应用程序并检查数据库时,不会进行任何更改。我还没弄清楚这一点。任何帮助都会很棒。谢谢。

Private Sub ButtonSaveScore_Click(sender As Object, e As EventArgs) Handles 
ButtonSaveScore.Click

    ScoresBindingSource.MoveLast()

    Dim scoreRow As ScoreboardDataSet.ScoresRow
    scoreRow = Me.ScoreboardDataSet.Scores.NewScoresRow()
    scoreRow.UserName = LabelPlayerName.Text
    scoreRow.Score = LabelWinsCounter.Text

    Me.ScoreboardDataSet.Scores.Rows.Add(scoreRow)

    Me.ScoresTableAdapter.Update(Me.ScoreboardDataSet)


    Try
        Me.Validate()
        Me.ScoresBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ScoreboardDataSet)
        MsgBox("Update successful")

    Catch ex As Exception
        MsgBox("Update failed")
    End Try
End Sub

0 个答案:

没有答案