有没有人有一个如何在vb.net中对两个数据表进行内部连接的示例?我已经尝试了几个我发现的例子,但到目前为止我还没有工作过。
答案 0 :(得分:4)
你的问题很模糊,但无论如何这可能有所帮助:
Dim both = From row1 In dataTable1.AsEnumerable()
Join row2 In dataTable2.AsEnumerable()
On row1.Field(Of String)("ColumnName") Equals row2.Field(Of String)("ColumnName")
For Each r1r2 In both
Dim row1 = String.Format("{0}", String.Join(",", r1r2.row1.ItemArray))
Dim row2 = String.Format("{0}", String.Join(",", r1r2.row2.ItemArray))
Console.WriteLine(String.Format("{0} | {1}", row1, row2))
Next