How get rid of the error "The source contains no DataRows."

im using this code to compare and get the common values in 2 data Tables but some time their are no common values in that case i m getting an error as above how can i move on when i received an error

(From x In output Join y In dt3 On x(“acc_no”).tostring Equals y(“LINE_DESCRIPTION”).tostring And x(" Amount").toString Equals y(“DR”).tostring
Select output.clone.LoadDataRow(New Object(){x(“Time”).tostring,x(" ID1").tostring,x(“TAmount”).ToString,x(" Ref Number").ToString,x(" PAN").tostring,x(“acc_no”).tostring,y(“GL_DATE”).tostring,y(“ATTRIBUTE2”).tostring,y(“LINE_DESCRIPTION”).tostring,y(“DR”).tostring,y(“CR”).tostring},False)).CopyToDataTable

@Tharusha_Fernando
we can handle with following pattern:

instead of using a copytodatatable we return a list of DataRows
with a check on the list count we can decide

  • there are rows: CopyToDataTable
  • there are no rows: Clone the Origin Datatable and receive an empty datatable with the same Columnstructure
1 Like

im getting an error when converting to a list when replaces copytodatatable to tolist

Just share the error message and/or more other error details with us.
Had you also changed the variable datatype from datatable to List(of DataRow) after replacing CopyToDataTable to toList?

i have convert the variable i think its in my code

ensure at least following

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