简体   繁体   English

ADO.NET tableadapter添加/更新/删除

[英]ADO.NET tableadapter add/update/delete

I'm using the table adapter in C# where visual studio generates the code for you. 我在C#中使用表适配器,Visual Studio在其中为您生成代码。 I have inserts and updates working just fine using the following code. 我使用以下代码可以很好地进行插入和更新。

However when trying to delete using the .update it gives me the following error. 但是,当尝试使用.update删除时,出现以下错误。

Update requires a valid DeleteCommand when passed DataRow collection with deleted rows. 当传递带有已删除行的DataRow集合时,更新需要有效的DeleteCommand。

this.workersTableAdapter.Update(this.nursery_dbDataSet_workers.workers);

Open the DataSet designer and click on the Adapter. 打开数据集设计器,然后单击适配器。 In the properties windows it has 4 Command properties, check the DeleteCommand . 在属性窗口中,它具有4个Command属性,请检查DeleteCommand It seems to be missing. 它似乎丢失了。

You cam rerun the wizard or write the Delete Sql by hand. 您可以重新运行向导或手动编写Delete Sql。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM