How should I handle this error: The source contains no data row

So it happens when I first: read range from my Excel file and I’m 100% sure the data is there I checked.

After that I use:

dt = dt.AsEnumerable().GroupBy(Function(r) Tuple.Create(r.Field(Of String)(“1 of my col:”), r.Field(Of String)(“my second column”), r.Field(Of String)(“my third column”))).Where(Function(g) g.Count() = 1).Select(Function(g) g.First()).CopyToDataTable()

and I get an error: The source contains no data row.

Why so? there are rows there. It works sometimes but I don’t understand why sometimes it does not work.

Any ideas?

Hi @marcin.chowaniec

You can try to Use Try catch activity

Check out this thread

Regards
Gokul

Yes but how does it help? I understand how to use the try catch but I’m trying to understand why that error might be? Is it possible that the code deletes all the rows so this error occurs?

OK I just read the article, thanks this must be it lol.

image

First use a IF condition and then get it

Use same expression like this

dt.AsEnumerable().GroupBy(Function(r) Tuple.Create(r.Field(Of String)(“1 of my col:”), r.Field(Of String)(“my second column”), r.Field(Of String)(“my third column”))).Where(Function(g) g.Count() = 1).Select(Function(g) g.First()).Any()

This will check if there is any rows first

If yes goes to then block where you can use a assign activity to get the records

Hope this helps
Cheers @marcin.chowaniec

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