Hi, I would like to filter the rows.
Code:
gue.Select(“[Client] like ‘“+Name+” ’ AND [Agent] like ‘DB2’ AND [Type] like '”+service1+“'”).CopyToDataTable
The agent is not fixed. It’s either ‘DB2’ or ‘SQL Server’.
So when I hardcoded the agent to be ‘DB2’, the error was thrown to the assign that the source contains no datarows.
I would like to look for this row this value, if it is not true, find another value.
Below is a sample of the dt
I tried this : serviceCatalogue.Select(“[Agent] like ‘SQL Server’”).Length > 0 - but does not work
Any solutions?
Thank you xoxo
ranjith
(Ranjith)
September 27, 2018, 3:24am
2
@sangasangasanga
Below method will return the rows count
yourdatatable.rows.count
To check datatable has rows
yourdatatable.rows.count > 0
Regards,
ranjith
Hi, your solution isn’t working. The error is still there
siddharth
(siddharth)
September 27, 2018, 4:19am
4
Instead of just checking for the count of Rows, Check if (dt3 is NOT nothing), after which check if dt3.Rows.count>0.
ranjith
(Ranjith)
September 27, 2018, 4:20am
5
@sangasangasanga
Try to print the rows count before IF activity.
Hi @siddharth
How do you do this? I tried IsNotNothing(dt3) but does not work
siddharth
(siddharth)
September 27, 2018, 7:14am
7
In your if condition, write one of these:
dt3 is nothing
isNothing(dt3)
Your else part will contain the code for when the table reference exists.
Check this and let me know if this solves your problem.
Hi guys @ranjith @siddharth @balupad14 , I tried all your suggestions. It was not working. Then I realized the problem isn’t in the ‘for each row’. It is the assigning of the filter rows. I have updated the question again. Pls take a look and help me if you can.
Thank you.
Uemoe
(Konstantin Marushchak)
September 28, 2018, 1:24am
10
split CopyToDatatable expression in two steps
First Array(of Datarow) filteredRows= gue.Select(“[Client] like ‘ “+Name+” ’ AND [Agent] like ‘DB2’ AND [Type] like ‘”+service1+“’”)
Than assign newDt = If(filteredRows.Any, filteredRows.CopyToDatatable, gue.Clone)
1 Like