Error: Sequence contains no elements

Hi, I get an error in a Assign activity.

Message: Sequence contains no elements
Exception type: System.InvalidOperationException.

The code in the assign activity is:

Save to: DT_filtered_empty_rows

Value to save: DT_filtered_empty_rows.AsEnumerable.Skip(DT_filtered_empty_rows.Rows.IndexOf(DT_filtered_empty_rows.AsEnumerable.Where(Function(r) r(1).ToString=“Tracktor”).Last)).CopyToDataTable

There is data in the data table, so what can cause this?

Hi @Evert_Randers ,

The Error is due to the use of Direct CopyToDatatable in the Expression, Check the below post on handling this case :

Hi, if understand this article correctly, this is for a situation where the filtered table has no rows, but in my case it do have rows. (and will always have). Am I missing something here?

@Evert_Randers ,

In that case, you could try Debugging this Expression in Parts, Go for the Inner Most Expression to validate using the Immediate Panel.

DT_filtered_empty_rows.AsEnumerable.Where(Function(r) r(1).ToString="Tracktor").Last


DT_filtered_empty_rows.Rows.IndexOf(DT_filtered_empty_rows.AsEnumerable.Where(Function(r) r(1).ToString="Tracktor").Last)

From the above two outputs we should be able to get to understand why the error occurs.

When testing the first part I get this error:

When testing the second part I get this error:


@Evert_Randers ,

This seems a check in the workflow. Was a Check done using the Immediate Panel as mentioned ?

Also, I guess the First Expression used was having a Typo Error in the Expression.

Check more on Debugging below :