Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi,

I have 3 tables that they are student table, lesson and result. What that I want to do is that I want to show student name and family in row and show lesson name in columm header and show student lesson grade how can I do this in DataGridView?

Thanx for your help
Posted
Updated 4-Mar-11 4:57am
v2

Yes you can do it. What you looking for is called Join Here is very brief intro http://www.w3schools.com/sql/sql_join.asp[^]

the example assumes what your tables may look like. You need to adjust it to fit your design.
SQL
SELECT first_name, family_name, lesson_name 
FROM students s
INNER JOIN lessons l
ON s.id = l.id
 
Share this answer
 
Comments
Manas Bhardwaj 4-Mar-11 11:03am    
OP said:
that was not my mean I want to make a cross table in datagridviw with 3 tables
You can use join query as Ysuf said (join the three tables using parent child relationship) and on the result of the join query use a pivoting query. That result can be bind to the gridview.

Here is an example of pivot query.

http://www.mssqltips.com/tip.asp?tip=1019[^]
 
Share this answer
 
Hi,

look at this Article:
C# Pivot Table[^]

Hope that helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900