Error the source contains no datarow

Hi
I have to filter the data>120 from excel. I have used attached logic but it gives following error as the source contains no data row.

Dt. AsEnumerable. Where(function(x) cint(“column name”)) >120). CopyToDatable. Rows. Count.

Please help on this. Hw to resolve this issue.if the data count is 0 I have to print 0.

Thanks in advance

Hey @sayalib

You can use Dt. AsEnumerable. Where(function(x) cint(“column name”)) >120). CopyToDatable this and store to datatable variable new_DT
After that do the if check new_DT.rows.count =0 then there is no data else vice versa.

Cheers @sayalib , let me know if this will work for you.

Hi @shreyash_shirbhate
I have tried that but same error occurred. I have tried in another way and solved that issue.
Create variable(row) as ienuberable datarow collection
Row=Dt. AsEnumerable. Where(function(x) cint(“column name”)) >120)

Then if (row.any)
Then find the counts.

But thanks for the response.

1 Like

CopyToDataTable Method throws this exception in case of an emtpy filter result and when no rows are returned. We can handle this defensively with an approach described here:

1 Like

Hi @sayalib

Please try,

Dt.AsEnumerable.Where(function(x) cint(x(“column name”))>120).count

Thanks

Or…
Go more lowcode. Loads if not most of RPA developers are not proficient is using .net expressions in that fashion. (Though it is very powerfull of course)

A simple filter datatable activity will achieve exactly te same.

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