Click here to Skip to main content
15,902,447 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I Have DataGridView View like this

StudRollNo Name
1 AAA
2 BBB
3 CCC

I want to Add Columns to DataGridView of Subjects Table which is also comes after selecting Standard using Datatable to Existing columns like StudRollNo,Name

I want Like This way

StudRollNo Name English Maths History
1 AAA
2 BBB
3 CCC

Can any one suggest the way....

thx in advance....
Posted
Updated 10-Feb-12 19:46pm
v2
Comments
RDBurmon 11-Feb-12 1:53am    
Please share you table structure .

1 solution

As per my understanding below could be the implementation to achieve this

suppose you have two table as per below

Table1 : Student


RollNumberName
1AAA
2BBB
3CCC


Table2 : Subject


RollNumberEnglishMathsHistory
1506070
2404550
3356538


then you query will be

SQL
SELECT S.Rollnumber,S.Name,Sub.English,Sub.Maths,Sub.History
 FROM Student S inner join Subject Sub On S.RollNumber=Sub.RollNumber


Hope this helps if yes then accept my answer and vote as well otherwise revert back with your queries.
--Rahul D.
 
Share this answer
 
Comments
Ravi Sargam 11-Feb-12 2:27am    
I have a table StudentMarks with Subject and StudentName.... columns
jai000 11-Feb-12 3:13am    
SubjectMarks table should have StudentID as Foreign Key. Reason is that two or more student can have same name. I would suggest add StudentID/StudRollNo as foreign key in your studentMarks table
Ravi Sargam 11-Feb-12 3:16am    
i have foreign key of StudentId and SubjectId
RDBurmon 11-Feb-12 5:41am    
Ravi , Could you please how many tables you have with there stucture and foreign keys with them so that I can guide you ?

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