I am getting an error “The source contains no Datarows”

Hi,

I am filtering records using linq based on the column Time, getting error like. “The source contains no DataRows”.

Source data

image

Dispatcher_DT.AsEnumerable().Where(Function(row)DateTime.Now.TimeOfDay.Subtract(DateTime.Parse(row(“Time”).ToString).TimeOfDay).TotalMinutes >= 50).CopyToDataTable()

Thanks
Shaik Muktharvalli

@shaik.muktharvalli1

use if condtion first in which you can check the count and then if count>0 then copytodatatable else it means no rows

condition : Dispatcher_DT.AsEnumerable().Where(Function(row)DateTime.Now.TimeOfDay.Subtract(DateTime.Parse(row(“Time”).ToString).TimeOfDay).TotalMinutes >= 50).Count>0

cheers

THIS Linq working on local studio but not in VM @Anil_G

is there any solution please

thanks
shaik

@shaik.muktharvalli1

this would work anywhere

there must be some issue…please check

or mention what is not working and we can check

cheers

have to get greater than 50 min compare to present time from “Time” Column

image

please give me update Linq @Anil_G

Thanks
Shaik

thank you @Anil_G condition working fine

1 Like

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