简体   繁体   English

C#联接2个不带LINQ的数据表

[英]C# join 2 DataTables without LINQ

I want to join two data tables using C# without using LINQ. 我想在不使用LINQ的情况下使用C#连接两个数据表。 How can I do it? 我该怎么做?

Are you trying to concatenate two datatables to a new one? 您是否正在尝试将两个数据表连接到一个新的数据表? If so, do this 如果是这样,请执行此操作

DataTable result= table1.Copy();
result.Merge(table2);

where table1 and table2 are DataTables 其中table1和table2是DataTables

use a single statment that joins the tables in SQL, ie 使用单个语句连接SQL中的表,即

select * from table1 t1, table2, t2 where t1.id = t2.id

HTH 高温超导

Ivo Stoykov 伊沃·斯托伊科夫(Ivo Stoykov)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM