我使用此代码将值保存到访问数据库
我做了什么。
代码:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TabelaBindingSource.AddNew()
End Sub
在按钮保存上添加此代码
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Try
Validate()
TabelaBindingSource.EndEdit()
TabelaTableAdapter.Update(EUUsersDataSet.tabela)
MessageBox.Show("Saved")
Catch ex As Exception
MessageBox.Show("Error during saving")
End Try
End Sub
弹出我的盒子"已保存"但数据库中没有记录我做错了什么?
我尝试通过TabelaBindingNavigator添加它,即使我按下该按钮仍然不会保存它。
答案 0 :(得分:0)
此代码适用于我:
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TabelaTableAdapter.Fill(Me.Database1DataSet.Table1)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.TabelaBindingSource.AddNew()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
Me.Validate()
Me.TabelaBindingSource.EndEdit()
Me.TabelaAdapterManager.UpdateAll(Me.Database1DataSet)
Catch ex As Exception
MessageBox.Show("Error during saving")
End Try
End Sub