Assign: Cannot perform '=' operation on System.Double and System.String error on datatale

i m getting above error when i m using IN operator in datatable.select
as
dt_datatable.select("[Item] IN ( ‘KVCARWAR-001-5000-LF’)").CopyToDataTable
but its working perfect when i use
dt_datatable.select("[Item] = ‘KVCARWAR-001-5000-LF’ ").CopyToDataTable

i need to use this condition on multiple dynamic values hence i need to use IN operator so the datatable can be filtered on multiple items or dynamic values like (‘KVCARWAR-001-5000-LF’,‘KVCARWAR-001-5600-LF’,‘KVCARWAR-001-6300-LF’,‘KVCARWAR-002-1130-LF’) of any count in future. so i can use a variable on this. but even for testing with one value using IN operator is giving error

appreciate any input to resolve this.

i saw many posts on this but none helped

Hi @gsunilusa ,
it should work, can you send the screen shot of the syntax. if any error that too

Regards,
Arivu

Hi,

There might be numeric data in Item column.
To isolate causes, can you try to remove numeric data if exists in Item column?

or

Can you try to use the following LINQ expression?

dt_datatable.AsEnumerable.Where(Function(r) {"KVCARWAR-001-5000-LF"}.Contains(r("Item").ToString())).CopyToDataTable()

Regards,

There is no syntax error . otherwise the process wont starting if any errors.
here is the screen shot.

This worked for me Yoichi.
i tried with one item dt_datatable.AsEnumerable.Where(Function(r) {“CBDATMIN-001-5000-LF”}.Contains(r(“Item”).ToString())).CopyToDataTable(). - it worked

tried 2 items dt_datatable.AsEnumerable.Where(Function(r) {“CBDATMIN-001-5000-LF”,“CBDATMIN-001-5600-LF”}.Contains(r(“Item”).ToString())).CopyToDataTable() - it Worked .

then i tried with dynamic values using a varaible as below
dt_datatable.AsEnumerable.Where(Function(r) in_read_filter_by_items.split(","c).Contains(r(“Item”).ToString())).CopyToDataTable()

and then tested with multiple values and the data filtered as per given values in the in_read_filter_by_items string variable = CBDATMIN-001-5000-LF,CBDATMIN-001-5600-LF,CBDATMIN-001-6300-LF,CBDATMIN-002-1130-LF,CBDATMIN-006-1130-LF,CBDATMIN-007-9600-LF,CBDATMIN-008-3900-LF,CBDATMIN-009-1130-LF

Thank you so much

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.