从数据表中删除行,但是求和无效. [英] delete row from datatable but sum,s not effect.

查看:122
本文介绍了从数据表中删除行,但是求和无效.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为dt&的数据表.当我从datagridview&删除行时,计算数据行(特定列)的总和并将其显示在文本框中.数据表
通过调用以下代码

I have a datatable called dt & computes the sum value of the data row (particular column) and shows it in a textbox,when i delete a row from datagridview & datatable
by calling the following code

dt.rows[0].delete();
dt.acceptchnges();



我希望从数据库中删除数据,但是当我重新查询数据库时,文本框值(显示总和值)不会改变.请有人帮助我





问候:
rahul



I expect the data to be deleted from the database but the textbox value (displaying the sum value) does not change when i requery the database.Please some one help me





regards:
rahul

推荐答案

dt.acceptchnges();

方法不会更新数据库,而是告诉数据表您所有数据表行都标记为rowState不变.
如果要更新数据库,则必须单独进行操作

method does not update the database but to tell the datatable that all your data table rows are marked as rowState to unchanged.

If you want to update the database you have to do seperately


使用sum()函数.....

例如.

query =从表中选择总和(列名)"


在这里,当您删除行时,...总和也不会扩展.
Use the sum() function.....

for example.

query="select sum(column name) from table"


here when u delete the rown also...sum does not effexts.


这篇关于从数据表中删除行,但是求和无效.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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