Check whether rows are available

Hi Everyone,

Wanted to check if a datatable doesn’t have any rows

If there are no rows/last row I need to send email

Or continue the loop

hi @keerthi65a

USE THIS EXPRESSION

(dt.Rows.Indexof(CurrentRow)+1).Equals(dt.Rows.Count)

here if it falls under then part …it is the last row and there would be no more rows…u can send notification

else part —continue the loop

1 Like

Hi

Use a if condition like this

dt.Rows.Count.Equals(1) OR dt.Rows.Count.Equals(0)

If yes it means it has only one row or zero row then goes to then block
If not else block

Cheers @keerthi65a

1 Like

Does it work inside for loop … because I am iterarting items

Hey does this work inside for loop I am iterating

hi @keerthi65a

above expression works as per the requirement …since u had mentioned loop earlier in post

so kindly give a try, basically i am targeting for loop index here

Hi @keerthi65a ,

Could you check with the below Expression :

DT.AsEnumerable.Any

Here, DT is the datatable variable, the above expression returns false if there are no rows available.

Maybe the scenario was more towards detecting the Last Row in the Datatable that was being looped, in that case, maybe we could use the below as well :

CurrentRow = DT.AsEnumerable.Last
1 Like

Yes it does if u r trying to validate on datatable whether it has 1 row or zero row

@keerthi65a

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