Source Contains No Data Rows || Link Query

Hi All,
Im using the below Query where
dt_file_name_match = (from r in dt_file_info.Select() where r(“File Name”).ToString.Trim.ToUpper.Equals(str_input_file.ToUpper.Trim.ToString) select r).CopyToDataTable.

In this Query dt_file_info = Data Table which consists ofFilename and File Path
str_input_file = filename

In this Link Query im getting Error as “Source contains no data rows”

Any suggestions ??

Hi,
Try below expression

dt_file_name_match = If((from r in dt_file_info.Select() where r(“File Name”).ToString.Trim.ToUpper.Equals(str_input_file.ToUpper.Trim.ToString) select r).count>0,(from r in dt_file_info.Select() where r(“File Name”).ToString.Trim.ToUpper.Equals(str_input_file.ToUpper.Trim.ToString) select r).CopyToDataTable,New Datatable)

Thanks for Quick Response. Tried the same. No success yet. Also the count is greater than 0. In beguf mode the data table ahs 5 rows data in it

dt_file_name_match = If((from r in dt_file_info.AsEnumerable where r(“File Name”).ToString.Trim.ToUpper.Equals(str_input_file.ToUpper.Trim.ToString) select r).count>0,(from r in dt_file_info.AsEnumerable where r(“File Name”).ToString.Trim.ToUpper.Equals(str_input_file.ToUpper.Trim.ToString) select r).CopyToDataTable,New Datatable)

Try this and let me know the result

CaptureI

@prerna.gupta

instead of New Datatable use dt_file_info.Clone

Instead of New Datatable, try New System.Data.DataTable or as @kumar.varun2 mentioned use dt_file_info.Clone

Yup it worked !! Thank You very much !!

1 Like

It worked for 1 activity.
But after clone-ing the original data table, in new data table i do not have any rows.
dt_file_name_match has only headers and No Data
Eg - Below Activity is failing as
str_filepath = dt_file_name_match .Rows(0)(1).ToString

@prerna.gupta

It will fail because there are no rows in the data table.

Correct !! So the purpose of using Link Query was to copy the row in New Data Table which we could not achieve

@prerna.gupta

What is the workflow?