Hi Team,
I am trying use “IN” Operator in where clause , getting an error like “)” expected.
Please help me on this…
I have been using the syntax like…
dt1=(From p In dt1.Select Where p(“Name”).tostring In(a) Select p).copytodatatable
Thanks in advance.
sarathi125
(Parthasarathi)
October 17, 2019, 9:30am
2
Hey,
can you elaborate on what you are trying to do here, which rows you want to copy.
Please try like this
Dt1.Select(“Name = ‘’(Name here)”).CopyToDatatable
I want to select particular rows using IN Operator in where clause
Like in a datatable if there are A,B, C Values in the column ,i want to select A, B rows
sarathi125
(Parthasarathi)
October 17, 2019, 9:47am
5
@prathima ,
Try with this query,
From r as DataRow in dt1.Rows Where lstNames.contains(r.Item(“Name”)) Select r
Here you need to have a List(of String) type variable named as lstNames with the values you want to filter. This will result as a IEnumerable Collection of DataRows
Hi Sarathi,
I am getting an error as in below screenshot…
Thanks,
sarathi125
(Parthasarathi)
October 17, 2019, 10:37am
7
This is working for me, please check this
(From r In dtOut.AsEnumerable() Where lstNames.Contains(r.Field(Of String)(“Name”)) Select r).CopyToDataTable
and assign this to a datatable in an assign activity
sarathi125
(Parthasarathi)
October 17, 2019, 11:01am
10
Before assign it to a datatable, check that using a IF with this condition.
(From r In dtOut.AsEnumerable() Where lstNames.Contains(r.Field(Of String)(“Name”)) Select r).Count > 0
This will avoid error if there is no row with the matching scenario.
system
(system)
Closed
October 20, 2019, 11:01am
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.