当传递包含修改行的数据行集合时,更新需要有效的更新命令
我正在尝试通过以下命令使用数据网格中的值更新访问数据库:
Private Sub btnUpdate_Click(ByVal source As Object, ByVal e As EventArgs) Handles btnUpdate.Click
Dim conn As New OleDbConnection(Con)
Dim bsource As BindingSource = New BindingSource()
Dim da As New OleDbDataAdapter
Dim dt As DataTable = ds.Tables("Config_access")
Me.DataGridView1.BindingContext(dt).EndCurrentEdit()
Me.da.Update(dt)
MsgBox("Table Updated")
End Sub
我面临主题行中提到的错误。请建议。
Am trying to update the access database with the values in the datagrid by the following command:
Private Sub btnUpdate_Click(ByVal source As Object, ByVal e As EventArgs) Handles btnUpdate.Click
Dim conn As New OleDbConnection(Con)
Dim bsource As BindingSource = New BindingSource()
Dim da As New OleDbDataAdapter
Dim dt As DataTable = ds.Tables("Config_access")
Me.DataGridView1.BindingContext(dt).EndCurrentEdit()
Me.da.Update(dt)
MsgBox("Table Updated")
End Sub
I am facing the error mentioned in the subjectline. Please suggest.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少一些部分。您需要数据适配器的命令对象和更新命令。您需要知道如何编写更新 SQL 语句。建议您使用参数来标识要更新的行。也许您的表有某种唯一的 id 字段(主键)?您可以在问题中包含一些表格信息,以获得有关如何执行此操作的反馈。
您可以从此处开始解决命令错误。如果您遇到其他错误,您可能需要重新发布。
There are a few pieces you have missing. You need a command object and an update command for your data adapter. You'll need to know how to write an update SQL statement. It is suggested you use parameters to identify which row you want to update. Maybe your table has some sort of unique id field (Primary Key)? You can include some of the table information in your question to get feedback on how to do that.
You can start here to address the command error. If you run into other errors, you may want to repost.