Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to ask you if you can help me

I have a web application by using visiual studio 2010( asp.net tech. written by c#)


There are two tables FirstTable (Id-Name) ,SecondTable (NameOfCourses-NumOfCourse)

in a data base there is no relation between these tables and no option to change the structer of these tables.


The problem I want to solve it:
I have gridview for the fisrt table and when I clicked on the name of student I want to navigate me to other page have the (Id-Name-NameOfCourses-NumOfCourse)

How can I merge beteween these unrelated tables to make one table.

Thank you for your help
Posted
Comments
OriginalGriff 9-Apr-11 3:18am    
Sorry?
If there is no relation between them, how do you expect to construct a single table out of the two?
Can you construct a single table out of a train timetable and your bank statement?
dedoooo 9-Apr-11 3:43am    
In SQL statment
I expected there is a possible way to make the Id as colum in second table but I don't know how make it?

Your question isn't very clear, perhaps an example would help. As OriginalGriff stated, if there's no relation between the tables, you cannot 'navigate' in the data.

However if you want to create all combinations of students and courses, you could create a cartesian product between them. For example:
var all = from student in FirstTable.AsEnumerable()
          from course in SecondTable.AsEnumerable()
          select {
             student.Id,
             student.Name,
             course.NameOfCourse,
             course.NumOfCourse
          }
This should contain all the combinations and you can put the results into a new datatable.
 
Share this answer
 
You can use cross join linke,-
SELECT     FirstTable.ID, FirstTable.Name,SecondTable.NameOfCourses,SecondTable.NumOfCourse 
FROM         FirstTable CROSS JOIN
                      SecondTable 
 
Share this answer
 
You must create an SQL view in the Management studio. Their you can combine tables: http://msdn.microsoft.com/en-us/library/ms187956.aspx[^]
 
Share this answer
 
You can make use of the student id which is in the first table....you have another colomn in the second table where student id is the foreign key...when the id is selected then correspondingly pass a query which the gets the value from the second table based on the student id...

if you want values from both the first and second table, write a query with inner join...
 
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