Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LINQ - Selection Syntax issue

Status
Not open for further replies.

shaunk

Programmer
Aug 20, 2001
402
AU
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).


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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top