如何使用访问数据库更新vb中数据绑定datagridview中的单元格 [英] How do you Update a cell in a databound datagridview in vb with access database

查看:48
本文介绍了如何使用访问数据库更新vb中数据绑定datagridview中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我所拥有的

this is what i have

Try
    Me.Validate()
    Me.EmployeeRegistrationBindingSource.EndEdit()
    Me.EmployeeRegistrationTableAdapter.Update(PayrollManagerDBDataSet.EmployeeRegistration)
    MsgBox("Update successful")

Catch ex As Exception
    MsgBox(ex.StackTrace, "Update failed")
End Try



但是我得到了这样的例外情况:


but i get the an exception like this:

System.Data.OleDb.OleDbException was unhandled
  ErrorCode=-2147467259
  HResult=-2147467259
  Message=An UPDATE or DELETE query cannot contain a multi-valued field.
  Source=Microsoft Access Database Engine
  StackTrace:
       at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
       at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
       at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
       at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
       at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
       at Payroll_Manager.PayrollManagerDBDataSetTableAdapters.EmployeeRegistrationTableAdapter.Update(EmployeeRegistrationDataTable dataTable) in D:\Payroll Manager(MS Access)\PayrollManagerDBDataSet.Designer.vb:line 18222







Try
    Me.Validate()
    Me.EmployeeRegistrationBindingSource.EndEdit()
    Me.EmployeeRegistrationTableAdapter.Update(PayrollManagerDBDataSet.EmployeeRegistration)
    MsgBox("Update successful")

Catch ex As Exception
    MsgBox(ex.StackTrace, "Update failed")
End Try

推荐答案

开始阅读这个 [ ^ ]。



访问权限与其他数据库不同。在Access中构建数据库时,数据库设计用于Access,而不是外部代码。这会导致某些问题,例如您遇到的问题。
Start reading this[^].

Access isn't like other databases. When you build a database in Access the database is designed to be used in Access, not outside code. This causes certain problems, like the one you're encountering.


这篇关于如何使用访问数据库更新vb中数据绑定datagridview中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆