filterDt.Select("[Name]='Tina'").CopyToDataTable is throwing the source contains no data rows error

Hi All,

I am trying to filter the data table and since there are no rows with that filter condition it’s throwing an exception saying “The source contains no DataRows”

How to proceed further?

What should happen: If there are no rows then I need to get the count as “zero” and write some logic towards that.

Hi @Krithi1

Can you try like below

rowCount = filterDt.Select("[Name]='Tina'").Length

If rowCount is 0, no rows match.
Otherwise, proceed with logic.

Regards,

HI,

Can you try to use datarow array as the following?

Regards,

Hi @Krithi1

Before going for filter datatable just check if datatable has any rows in it or not.
You can check that by using assign activity

rowCount = dt.Rows.Count

If rowCount > 0
    Message Box: "Put your Filter condition here"
Else
    Message Box: "No Rows in datatable"

Hope this helps :slight_smile:

@AJ_Ask

The actual table has rows. Only when i filter there are no rows.this is not a solution for me i believe

Hi, i am not understanding this logic. Can tou please explain

Hi,

CopyToDataTable methods throws exception if instance has no rows.
To avoid this, first, set result rows of Select method into datarow array (arrDr). Then check if arrDr has any items using Any method in condition of IF activity.
If arrDr has one or more rows, convert it to DataTable using CopyToDataTable method.
If arrDr has no row, set empty datatable from filterDt using Clone method.

Hope this helps you.

Regards,

@Yoichi

What is the variable type for datarow array? I am not finding it. Is it datarow compare?

Hi,

Can you try as the following?

First, choose Array of [T], then choose DaraRow.

Regards,

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