Finding datatable is empty

I am filtering a DT using linq with
dt_Header.Select("[xyz] = ‘yes’").CopyToDataTable but sometimes data is not coming regarding this condition so there is no row and UiPath is giving error ‘Source has no Datarows’. It is returning no datarows, How can i check this into if condition? how can i find a DT is blank or empty?

You can use try catch activity put dt_Header.Select("[xyz] = ‘yes’").CopyToDataTable into the try catch
if any error thrown by the code execute catch activity where you assign a variable to check the catch activity execute or not.

Use Data Filter Table activity instead.

Check your weither your columns have header ? If yes put as colmun if not put colmun number like “Column0”. Than choose contains or equal, to filter your data.

This will be save on a DT, you can later check weither on an excel file or just on console…

@Sachin129 You can First Check in If Block as :
dt_Header.Select("[xyz] = ‘yes’").ToArray.Count>0
if True Continue with Assign : dt_Header.Select("[xyz] = ‘yes’").CopyToDataTable
you can handle it however you want depending on the further Steps you have used

Thanks buddy, its worked!

1 Like

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