I am performing a left join on two data tables (dt_Clients and dt_ConnXclients) using Linq. The problem I have is the select statement, where I am trying to return an array of datarows to populate a data table I have created with columns from both tables (duplicate removed).
The error message I am receiving is System.ArgumentException was unhandled by user code
Message="Unable to cast object of type 'System.Object[]' to type 'System.IConvertible'.Couldn't store <System.Object[]> in Client_Id Column. Expected type is Decimal." Source="System.Data"
StackTrace:
at System.Data.DataColumn.set_Item(Int32 record, Object value)
at System.Data.DataTable.NewRecordFromArray(Object[] value)
at System.Data.DataRowCollection.Add(Object[] values)
I am being driven mad by this so any help much appreciated. .
What gets us into trouble is not what we don’t know, its what we know for sure that just ain’t so.
Code:
Dim tablesJoined2 = From t1 In (dt_Clients.Rows.Cast(Of DataRow)()) _
Group Join t2 In (dt_ConnXclients.Rows.Cast(Of DataRow)()) _
On t1("Service_Request_Id") Equals t2("Service_Request_Id") _
Into RightTableResults = Group _
From ds1row In RightTableResults.DefaultIfEmpty() _
Select t1.ItemArray.Concat(ds1row.ItemArray.Where(Function(r2) ds1row.ItemArray.Contains(r2) = False)).ToArray()
'Then
For Each values As ????? In tablesJoined2
targetTable.Rows.Add(values)
Next
The error message I am receiving is System.ArgumentException was unhandled by user code
Message="Unable to cast object of type 'System.Object[]' to type 'System.IConvertible'.Couldn't store <System.Object[]> in Client_Id Column. Expected type is Decimal." Source="System.Data"
StackTrace:
at System.Data.DataColumn.set_Item(Int32 record, Object value)
at System.Data.DataTable.NewRecordFromArray(Object[] value)
at System.Data.DataRowCollection.Add(Object[] values)
I am being driven mad by this so any help much appreciated. .
What gets us into trouble is not what we don’t know, its what we know for sure that just ain’t so.