[英]DataGridview won't update/delete
I'm using an access database in a C# project. 我在C#项目中使用Access数据库。 I also have a DataGridView to display and edit the table.
我也有一个DataGridView来显示和编辑表。 It works fine when I'm adding a new line but I get an exception when deleting/editting an existing line.
当我添加新行时,它工作正常,但是删除/编辑现有行时出现异常。
Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.
the relavent Code: 相关代码:
private void updateB_Click(object sender, EventArgs e)
{
this.complaintsTableAdapter.Update(this.databaseDataSet.complaints);
this.complaintsTableAdapter.Fill(this.databaseDataSet.complaints);
}
you must set some settings in complaintsTableAdapter
您必须在
complaintsTableAdapter
设置一些设置
in TableAdpater
set Insert
, Update
, Delete
Command or if you create table adapter automatically from designer can use 在
TableAdpater
设置Insert
, Update
, Delete
命令,或者如果您从设计器自动创建表适配器,则可以使用
Create method to send updates directly to the database (GenerateDBDirectMethods)
this can fix your problem 这可以解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.