我刚刚发现了 CommandBuilder,并认为它听起来很直接且易于使用。显然我仍然缺少一些东西。我有一个 DataGridView 可以成功更新名为 Customers 的 dbSet 表。但它没有更新到实际的数据库文件:
...
Dim ConMain As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\dummy_data.accdb")
...
Private Sub CustomerDataGridView_RowValidated(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
Handles CustomerDataGridView.RowValidated
Me.CustomersTableAdapter.Update(Me.Dummy_dataDataSet.Customers)
Dim CustomerAdapter As New OleDbDataAdapter("Select * From Customers", ConMain)
Dim ObjComander As New OleDbCommandBuilder(CustomerAdapter)
CustomerAdapter.Update(Dummy_dataDataSet, "Customers")
End Sub
它不会抛出错误,并且我所做的任何更改都保存在内存中(我可以打开和关闭表单并且更改将保留),但它们实际上并未写入数据库。我错过了什么?