TableAdapter.Update()不会从数据库中删除记录 [英] TableAdapter.Update() not deleting records from DB

查看:138
本文介绍了TableAdapter.Update()不会从数据库中删除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为表tbl_Cust创建了一个数据集.在代码中创建了一个类型为数据表custtb的tableadapter对象适配器,然后通过代码在我的数据表custdb中插入了2行,更新了2行并删除了2行. 然后我打电话给adapter.Update(custtb)在我的数据库中进行更新.
插入和更新的记录反映在数据库中.但是被删除的文件实际上并没有从数据库中删除.

数据库更新的代码就像

I have created a dataset for my table tbl_Cust.In code created a tableadapter object adapter n a typed datatable custtb.then i have inserted 2 rows, updated 2 rows and deleted 2 rows in my datatable custdb thru code.
then i called adapter.Update(custtb) to update same in my DB.
Inserted&Updated records are reflecting in DB. But the deleted one are not actually removed from DB.

The code for DB update is like

this.dataSetDataTableFromDBBindingSource.EndEdit();
this.Validate();
this.adapter.Update(this.custtb);


我的适配器删除命令是正确的.我无法使用适配器的删除方法并删除每一行,因为我想批量这样做.
任何人都知道哪里出了问题?????
在此先感谢


my delete command of adapter is correct.I cant use delete method of adapter and delete each rows as i wanna do it in bulk.
Anyone idea on where it goes wrong?????
Thanks in advance

推荐答案

Der Friend
如果存在任何关系,则可能会导致问题(希望您知道).
如果使用存储过程执行操作,请检查存储过程,以便比较正确与否

问候
Vipin Kumar
Der Friend
If there is any relation ship then it may cause problem(hope you know).
If you are using stored procedure to perform operation then check the stored procedure so that the comparison is correct or not

regards
Vipin Kumar


感谢Vipin,

但是我使用的是直接SQL命令,而不是SP.也没有关系,因为我的数据集代表一个表.

Nishitha
Thanks Vipin,

But Im using direct SQL command, not a SP. Also there is no relationship as my dataset stands for a single table.

Nishitha


希望 [ ^ ]可能会给您一个想法.
Hope this[^] might give you an idea.


这篇关于TableAdapter.Update()不会从数据库中删除记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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