[英]DataGridview won't update/delete
我在C#项目中使用Access数据库。 我也有一个DataGridView来显示和编辑表。 当我添加新行时,它工作正常,但是删除/编辑现有行时出现异常。
Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.
相关代码:
private void updateB_Click(object sender, EventArgs e)
{
this.complaintsTableAdapter.Update(this.databaseDataSet.complaints);
this.complaintsTableAdapter.Fill(this.databaseDataSet.complaints);
}
您必须在complaintsTableAdapter
设置一些设置
在TableAdpater
设置Insert
, Update
, Delete
命令,或者如果您从设计器自动创建表适配器,则可以使用
Create method to send updates directly to the database (GenerateDBDirectMethods)
这可以解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.