The fields in which will be selected will change each time. Also, I am selecting from several lists so it makes it hard to use a string list.
Here is my code: (Note: This works manually but once the field names change it will not work.)
As you can see I am selecting different fields from two DataTables. However, the name and quantity of these fields will change often. I came up with the following solution but it won't work with multiple lists. (Note: I already populated the string list "ListOfColumnNames" prior to running this code)Code:Dim both = From row1 In AddressListDatatable.AsEnumerable() Join row2 In Matrix1Datatable.AsEnumerable() On row1.Field(Of String)("Offercode") Equals row2.Field(Of String)("Code") Select row1("Account") & "," & row1("First") & "," & row2("CODE") & "," & row2("SWITCH")
Here is that code:
Code:Dim both = From row1 In AddressListDatatable.AsEnumerable() Join row2 In Matrix1Datatable.AsEnumerable() On row1.Field(Of String)("Offercode") Equals row2.Field(Of String)("Code") Select String.Join(", ", From i In ListOfColumnNames Select row1(i))




Reply With Quote
