I am trying to recreate an Access/SQL like view builder in VB.net
I have two DataTables, AddressListDataTable and MatrixDataTable
These two DataTables will be combined with LINQ and added to a third DataTable called CombinedDataTable
My Issue is that the fields in both the AddressListDataTable and MatrixDataTable will change often, so I need to figure out how to build a custom Select Statement.
Here is my code: (Highlighted is the line that will change often because the field names will change)
The highlighted row actually works, but it is a manual solution. I will be selecting different fields each time because the AddressListDataTable and MatrixDataTable content will be populated with different data and column names each time.Code:Dim both = From row1 In AddressListDatatable.AsEnumerable() Join row2 In MatrixDatatable.AsEnumerable() On row1.Field(Of String)("Offercode") Equals row2.Field(Of String)("Code") Select row1("Account") & "|" & row1("First") & "|" & row1("OFFERCODE") & "|" & row2("Expiration") & "|" & row2("OfferDescription")
So, how do I create a custom select statement each time the code is ran?
Also, here is how I am adding the data to the CombinedDataTable:
Code:For Each r1r2 In both Dim words As String() = r1r2.Split(New Char() {"|"c}) CombinedDataTable.Rows.Add(words) Next




Reply With Quote
