Reputation: 113
Does anyone have an example of how to do an inner join on two datatables in vb.net? I have tried several examples that I found but I haven't gotten one to work thus far.
Upvotes: 1
Views: 6826
Reputation: 460068
Your question is pretty vague, but maybe this helps anyway:
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
Upvotes: 5