如何向DataGridView显示2个表数据。 1表数据需要标题文本 [英] How to Show 2 Table Data to DataGridView. 1 Table Data need Header Text

查看:57
本文介绍了如何向DataGridView显示2个表数据。 1表数据需要标题文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好请帮帮我...

我有3个桌面视图到DataGridView





此表数据需要显示



Hi All Please Help Me...
I have 3 Table View to DataGridView


This Table Data Want Display

Table1 (StudentDetails)			
Regno	Name	Class	Section
A100	Raja	I	A
A200	Ravi	I	A





此表提交显示到DataGridView列



表2(费用结构)



This Table Filed Want Display To DataGridView Column

Table2(Fees Structure)

Class	FeeType	Total Amount	
I	Jan	1500	
I	Feb	2500	
I	Mar	1500	
I	Apr	3000	
I	Other	500







此Talbe数据显示DGV

表3(FeesTrans)




This Talbe Data Show to DGV
Table3 ( FeesTrans)

Regno 	Sname	Class	FeeType	Amount
A100	Raja	I	Jan	1000
A100	Raja	I	Jan	500
A100	Raja	I	Feb	2500
A100	Raja	I	Other	500
A200	Ravi	I	Jan	1500
A200	Ravi	I	Other	500





我要DataGridView赞这个







I want DataGridView Like This


Regno	Sname	Class	Section	Jan	Feb	Mar	Apr	Other	Total
A100	Raja	I	A	1500	500	0	0	500	2500
A200	Ravi	I	A	1500	0	0	0	500	200

推荐答案

试试这个。只需修改查询并加入所需的表格。

try this. just modify the query and join the needed tables.
SELECT Regno, Sname, Class, Section,
SUM(CASE WHEN FeeType = 'Jan' THEN Amount ELSE 0 END) AS Jan,
SUM(CASE WHEN FeeType = 'Feb' THEN Amount ELSE 0 END) AS Feb,
SUM(CASE WHEN FeeType = 'Mar' THEN Amount ELSE 0 END) AS Mar,
SUM(CASE WHEN FeeType = 'Apr' THEN Amount ELSE 0 END) AS Apr,
SUM(CASE WHEN FeeType = 'Other' THEN Amount ELSE 0 END) AS Other,
SUM(FeeType) AS 'Total'
FROM <TableName>
GROUP BY Regno


这篇关于如何向DataGridView显示2个表数据。 1表数据需要标题文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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