question

TZacks-2728 avatar image
0 Votes"
TZacks-2728 asked StefanKrieger-9526 commented

LINQ: Datatable and List join return source contains no data row

I am joining a datatable and List<string> but getting error that source contaisn no datarow. here is my code. please tell me what mistake i have made for which i am getting error. both list<string> and datatable has data.

                     var result = (from bkr in ds.Tables[2].AsEnumerable()
                                   join prd in Listofperiods
                                       on bkr.Field<string>("StandardDate") equals prd.ToString()
                                   where string.IsNullOrEmpty(bkr.Field<string>("StandardValue"))
                                   select bkr).CopyToDataTable();


dotnet-csharp
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Maybe there are no such rows. Or maybe the comparison of dates is incorrect.

1 Vote 1 ·

How do the values for StandardDate and prd look like?

Maybe your dates have different notations. Try this.


 var result = (from bkr in ds.Tables[0].AsEnumerable()
                           join prd in Listofperiods
                               on DateTime.Parse(bkr.Field<string>("StandardDate")).ToString("yyyyMMdd") equals DateTime.Parse(prd).ToString("yyyyMMdd")
                           where string.IsNullOrEmpty(bkr.Field<string>("StandardValue"))
                           select bkr).CopyToDataTable();
0 Votes 0 ·

0 Answers