Assign:The source contains no datarows?

Hi all,
I wrote a LINQ query below i have mentioned, am getting the source contains no datarows.
can any give me the solution.
(
From row In UAT_Competency_DT_new
Let exists = Prod_competency_DT.AsEnumerable.Any(Function(x) x(“Expand AllCollapse All”).ToString = row(“Expand AllCollapse All”).ToString)
Select If(exists, Prod_competency_DT.Rows.Add({}), row)
).CopyToDatatable

Thank you

Hello @Vanitha_VS, If the variable that you created to copy the data table, then use
DT_Created= New Datatable

HI @Vanitha_VS

Seems like you have no datatrows that are true based on your condition ,Can you share sample input and expected output ?

Regards
Sudharsan

Hi Vanitha

You need to initialize the datatable against which you are writing the LINQ. If the schema of output datatable is same as that of input datatable. Then You can initialize the output datatable as below-
outDt = inputDt.clone

If the schema output datatable is different from input datatable then you can to use build datatable activity to define the schema to initialize the Datable.

Regards

hey @Vanitha_VS,

Keep your assign activity in try-catch; if there is no data row, it goes to catch, and in the catch, you will use build datatable activity to build the datatable without any data.

Happy Learning😊
Achal Sharma

Hi @Vanitha_VS

This error saying like there is no data row in the output Dt. So you can handle it via Try - Catch activity inside the Try use this expression and in the catch Use some Log message activity.

Regards
Gokul

Hi @Vanitha_VS ,

Could you let us know what are you trying to perform using the Linq mentioned ?

Also, Could you check the below post on resolving errors when Direct CopyToDatatable is used :

Hi @Vanitha_VS ,

Please check for the row count before copying it to datatable. Meaning - Assign the below block to a variable with appropriate data type = (
From row In UAT_Competency_DT_new
Let exists = Prod_competency_DT.AsEnumerable.Any(Function(x) x(“Expand AllCollapse All”).ToString = row(“Expand AllCollapse All”).ToString)
Select If(exists, Prod_competency_DT.Rows.Add({}), row)
)

Assuming that the variable name is drRows, check whether the count is greater than 0. eg - drRows IsNot Nothing AndAlso drRows.Count > 0

You need to take appropriate action in the else case. Let us know how it works

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