问题描述
我想问你是否可以帮助我
我使用visiual Studio 2010(由c#编写的asp.net技术)有一个Web应用程序.
有两个表FirstTable(Id-Name),SecondTable(NameOfCourses-NumOfCourse)
在数据库中,这些表之间没有关系,也没有更改这些表的构造方法的选项.
我要解决的问题:
我在fisrt表上有gridview,当我单击学生的姓名时,我想导航到其他页面,并显示(Id-Name-NameOfCourses-NumOfCourse)
如何在这些不相关的表之间合并以组成一个表.
谢谢您的帮助.
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
推荐答案
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.
SELECT FirstTable.ID, FirstTable.Name,SecondTable.NameOfCourses,SecondTable.NumOfCourse
FROM FirstTable CROSS JOIN
SecondTable
这篇关于将两张桌子合为一张桌子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!