Unable to assign values to datarow object

Hi All,

I am trying to filter out data using the “Query Entity Records” Entity and add those data to an Excel sheet. I followed the below steps and I am unable to load the data to a datatable before creating an Excel file.

  1. Filter the data using “Query Entity Records” (Works fine)
  2. Using the “For Each” activity to navigate through the filtered items

  1. Initialize a new variable named “datarow”, datatype System.Data.DataRow
    image

  2. Use “Multiple Assign” activity to assign values for “datarow” as below
    Datarow[“ProjectCode”] = currentItem.ProjectCode

    ProjectCode is the column name
    image

I am getting below error when I try to use above.

But when I use the Datarow[0], I get as below in the excel which is not expected column names
image

  1. use “Add Data Row” as below

image

I am using UiPath 2023.10 UiPath
Language: C#
Compatibility: Windows

Appreciate your kind support in assigning filtered values to datarow object.

Thanks

@Kavindu_Dilshan

Use add datarow activity to add data row into your datatable

Hi @Kavindu_Dilshan

Use Add data row activity, Pass the datarow object
image

Hope it helps!!

Hi @rlgandu @pravallikapaluri ,

I have multiple values assign to a data row, How do I achieve that?
After multiple assign activity, I am using “Add Data Row” as below.

image

@Kavindu_Dilshan

// Inside the “For Each” loop
DataRow newRow = dataTable.NewRow();
newRow[“Column1”] = value1; // Assign value to Column1
newRow[“Column2”] = value2; // Assign value to Column2
// Assign values to other columns if needed
dataTable.Rows.Add(newRow); // Add DataRow to DataTable

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