table适配器未更新本地数据库table

tableadapter not updating local database table

我有一个登录表单,应该将登录的用户保存到 table 并在他们退出应用程序时将其删除。问题是当 运行 table 适配器中的更新方法时,它 returns 没有错误但不更新数据库 table

代码如下:

  Sub passwordValid()
    Hide()
    Try
        Dim userIDAdd As String = DataGridView1.Rows(0).Cells(0).Value
        Dim userRightsAdd As String = DataGridView1.Rows(0).Cells(4).Value
        Dim CurrentDateTime As Date = Now

        Dim AddRow As DataRow = LocalDB1DataSet.Tables("LoggedOn").NewRow
        AddRow(0) = userIDAdd
        AddRow(1) = userRightsAdd
        AddRow(2) = CurrentDateTime
        LocalDB1DataSet.Tables("LoggedOn").Rows.Add(AddRow)
        Try
            Me.Validate()
            Me.LoggedOnBindingSource.EndEdit()
            Me.LoggedOnTableAdapter.Update(Me.LocalDB1DataSet.LoggedOn)
            MsgBox("Logged In as: " & LoggedInUser)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
    Main.Show()
End Sub

如有任何帮助或解释,我们将不胜感激。

我根据@jmcilhinney 的说法做了一些研究:

Update returns 1 then one record was saved. If you have followed the link I provided then you should know by now that you are looking in the wrong database and, by default, the right database to look in gets overwritten each time you rebuild your project.

事实证明并非完全如此,但它让我找到了这样做的原因。每次编译时,它都会替换旧的数据库,但该数据库保持为空,但如果应用程序是 运行 通过 VS,它会创建数据库的备份数据库,当应用程序在 VS 中停止时,它会恢复已发布的DB 与备份 DB。这是我自己的结论。