in a add data row activity…can anyone tell me what does this section means ?? (“Data row tab”)
or like what values to be added there ?
in a add data row activity…can anyone tell me what does this section means ?? (“Data row tab”)
or like what values to be added there ?
You can pass an array into ArrayRow, or you can pass a Datarow into DataRow. Datarow is a variable type. You can create a variable as a data row, and values to it, then pass it.
Hi @Jiban_Kumar_Das,
Assuming the datatable being used is not dynamically built i.e., you know the table schema ( column names and datatype of the column) you can use Add Data Row activity.
It expects an array as input where the index follows the table columns structure.
For example
Header1 (string) | Header2 (int) | Header3 (string) |
---|---|---|
data1 | 1 | data3 |
You can pass { “DataColumn1”, 3, “DataColumn3"} in the add data row activity.
Your resulting datatable will be
Header1 (string) | Header2 (int) | Header3 (string) |
---|---|---|
data1 | 1 | data3 |
DataColumn1 | 3 | DataColumn3 |
It is a very handy activity to have in your datatable arsenal
Hope this clarifies your doubt.
Thanks sir for enlightening me but
the method you explained,is only working in “Array row” tab ,not in “Data row”
when im dynamically trying to add multiple values
its giving me "1 dimensional array of object cannt be converted into system.data.datarow
sir if you dont mind can you please attach a small automation explaining this
Thank You
A DataRow is an object that contains a row of data. You can create a variable of type DataRow then add data to it with Assigns.
Hi @Jiban_Kumar_Das,
Think of DataRow as a object with n number values in it. It is not an array so using array in that field will not work. Rows in a datatable belong to the DataTable.DataRow Class in .net. DataRow Class (System.Data) | Microsoft Learn
But how do you use the two in UiPath?
Add Data Row —> using DataRow property
When we use a For Each Row
activity, then we are addressing a row and it is in form of DataRow
.
To get to the value of the row, we then can use row("ColumnName").ToString
Here you are using the DataRow (as row) and pooling the column you are interested in to get the value.
To add data using DataRow you will first need to make a NewRow
in the Sample DataTable and later append values to the columns.
NewDataRow=SampleTable.NewRow
NewDataRow("Column1")="test4"
NewDataRow("Column2")=4
There are different ways of getting importing rows from other tables, which you can see here:Copying Data from one DataTable to Another using ImportRow. But as per my know-how UiPath uses Add method when you use the Add Data Row —> DataRow. You can read more about Add
method here: DataRowCollection.Add Method (System.Data) | Microsoft Learn.
Add Data Row —> using ArrayRow property
On the contrary when you use an array you only need to know that the array has the correct sequence with respect to the column order. If you do not want to add some values you can use Nothing. For example (“Column1”, Nothing)
{"text3",3} to SampleTable
You can refer this workflow to know how to add rows using both methods:
DataRowVSArrayRow.xaml (12.2 KB)
Practice
You can try both methods with an exercise : https://docs.uipath.com/activities/docs/manage-databases-in-excel
Hope this helps. I learnt a new method, which I can use in my automations (DataRowCollection.Find Method (System.Data) | Microsoft Learn) so thanks for your question!
Thank you sir
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.