I am parsing an Excel workbook and extracting the data into two DataTables like so:
If SetDBConnect("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath & ";
Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""", True) Then
'Get total dollars table
sql.Append("SELECT * FROM [" & totalDollars & "]")
dt = _dh.GetTable(sql.ToString())
sql.Length = 0
sql.Append("SELECT * FROM [" & totalUnits & "]")
dt_units = _dh.GetTable(sql.ToString())
End If
The two spreadsheets are exactly the same with one difference. In the “Total Dollars” spreadsheet, there is a column with the dollar amounts, where in the “Total Units” spreadsheets, it is instead a column with unit amounts.
I would like to INNER JOIN these two tables WHEN the tableA.UPC = tableB.UPC. Is this possible? I have read about DataSets and DataRelations, but I was wondering if there was a simpler approach?
Thanks!
A simple approach using Linq would be: