2表显示在1个DataGridView中 [英] 2 Table Show in 1 DataGridView
问题描述
表1
RegNO名称PaidAmount级别部分
A100 AAAA 750 I A
A200 BBBB 750 I B
A300 CCCC 750 I A
A400 DDDD 750 I A
表2
RegNO名称金额类别
A100 AAAA 1500 I A
A200 BBBB 1500 I B
A300 CCCC 1800 I A
A400 DDDD 1500 I A
我想要DatagridView赞这个
RegNO名称PaidAmount金额班级部分
A100 AAAA 750 1500 I A
A200 BBBB 750 1500 I B
A300 CCCC 750 1800 I A
A400 DDDD 750 1500我A
请帮助我...解决这个问题..
Table1
RegNO Name PaidAmount Class Section
A100 AAAA 750 I A
A200 BBBB 750 I B
A300 CCCC 750 I A
A400 DDDD 750 I A
Table2
RegNO Name Amount Class Section
A100 AAAA 1500 I A
A200 BBBB 1500 I B
A300 CCCC 1800 I A
A400 DDDD 1500 I A
I want DatagridView Like This
RegNO Name PaidAmount Amount Class Section
A100 AAAA 750 1500 I A
A200 BBBB 750 1500 I B
A300 CCCC 750 1800 I A
A400 DDDD 750 1500 I A
Please Help Me.. for this problem..
推荐答案
您只需要编写一个结合两个表格数据的查询,并将其显示为网格的数据源。
还有其他wya要返回在前端分别打破两个表然后合并 - 但我不建议这样做,因为在DB级别将它们组合起来要容易得多。
样本:
You just need to write a query that combines the data of two table tables and show it as datasource of your grid.
There is other wya to retrieve both tables separately on front end and then combine - but I would not suggest this as it would be much easier to combine them at DB level.
Sample:
SELECT
t1.col1, t1.col2, t2.col3
FROM
table1 t1
INNER JOIN
table2 t2
ON t1.RegNO = t2.RegNO
结果集将具有可直接设置为网格源的组合数据。
Result set would have combined data that can directly be set as source for grid.
这篇关于2表显示在1个DataGridView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!