使用oledb将数据从不同的差异查询合并到行中 [英] Merge data into rows from differ difer query using oledb
问题描述
现在我正在使用Account软件,因此在C#2008的最后一个datagridview中,我想在不同行中同时合并借方和贷方字段以及期初余额,因此对此的最佳方法是什么?
谢谢你提前
萨特南·辛格
Muktsar
Now i work on Account software so in the last of the datagridview in C# 2008 I want to sum of both debit and credit field and opening balance also in different row so what is the best way regarding this please help
Thank You Advance
Satnam singh
Muktsar
推荐答案
您可以通过以下两种方式进行操作:
1)循环处理DataGridView中的所有行
用伪代码:
You can do it in 2 ways:
1) loop thrue all rows in DataGridView
In pseudocode:
For i = 0 to DGV.Rows.Count-1
sum+=DGV.Rows[i].Item["Debit"].Value
Next
2)从查询中获取总和
2) get sum from query
SELECT SUM(Debit) AS [SumOfDebit]
FROM TableName
WHERE condition
我不知道:
a)您想要显示它的位置(在DGV的最后一行还是在文本框中?),
b)数据源(SQL Server,Access等?)
如果您提供更多信息,我将改善我的答案.
I don''t know:
a) where you want to show it (in the last row of DGV or in the textboxes?),
b) the source of data (SQL Server, Access, etc.?)
If you provide more information, i''ll improve my answer.
这篇关于使用oledb将数据从不同的差异查询合并到行中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!