DataRow Item Array Convert into Datatable

Hi Team

In that for each row activity datatable into datarow itemarray

can you tell me how to convert item array into Datatable uisng linq.


What do you mean? You already have it in a datatable. That’s what Dtsh1 is.

Hi @Shyam_Pragash
E.g. having an empty datatable in place with 1 column or just had prepared it with a build datatable activity - dtResult we can do:

arrVals = {“abc”,“def”,“ghi”}

Assign activity:
LHS: dtResult

(From x in arrVals
Select r = dtResult.Rows.Add(new Object(){x})).CopyToDataTable

Or Method syntax:
arrVals.Select(Function (x) dtResult.Rows.Add(new Object(){x})).CopyToDataTable

Hope it helps


If you are trying to add the datarow to a different datatable then use. Add data row activity with array row property as row.Itemarray

Hope this helps


Hi @postwick

dtsh1 is datatable each row item convert into datatable

how to do it.



Then you can just use both inside loop

  1. dtnew = dtsh1.Clone()

  2. And then add data row

Dtnew will now have only one row for each iteration

Also if you need only row always…you can as well use this inside loop

Dtnew = dtsh1.Skip(index).Take(1).CopyToDataTable

Here index is the for loop index property


Hi @Parvathy

In for each row item convert into datatable… i give small amount of into… each row items convert into datatable…


Hi @Anil_G

U are right…

Each row item check with other sites values and then dynamically insert into SQL Sever using Insert Datatable activity… So that i want to convert into datatable…

few input data given in above post… i though only way for each row activity.

Can you tell me. how to convert it using linq in UiPath



In either ways ypu need a for loop…as you need each row as separate datatable…

Both the ways are given above already…both would work the same way

Please try the same


Hi @Shyam_Pragash

Here’s an example with some sample code:

// Sample DataRow with ItemArray
DataRow row = dataTable.Rows[0]; // Assuming you have a DataTable named ‘dataTable’

// Step 1: Create a new DataTable with the desired structure
DataTable newDataTable = new DataTable();

// Step 2: Add columns to the new DataTable based on the structure of the DataRow
foreach (object item in row.ItemArray)
newDataTable.Columns.Add(item.GetType()); // Assuming the data types match your requirements

// Step 3: Add the ItemArray as a new row to the DataTable

This code creates a new DataTable (newDataTable ) with columns matching the data types in the DataRow’s ItemArray and adds the ItemArray as a new row in the DataTable. Please note that this approach assumes that the data types in the DataRow’s ItemArray match your desired structure for the new DataTable. You may need to adapt the column creation logic if your requirements are more complex.


WHY do you want to convert each row into a datatable? It’s not a normal thing to do. What is your goal?

Hi @postwick

After converting into Datatable… i have insert data sql server (dynamic based on the columns)


You can just give the whole existing datatable to the Insert activity. You don’t have to do it row by row.

Hi @postwick

ur right… I know.

First get row item to check with other Application and if value is present get the value from application and insert to row item, get value. row item and get values are insert into dynamic columns in sql server


Then use the Execute Query activity and use currentRow and store the value from the app in a variable to build your custom query, not Insert.

Ok Thanks

I will try