Please can you help me with the expression I need to write in an assign activity to get the first row from my data table.
It has two columns so I want to get the data from both columns.
I can see that ExtractDataTable.Rows(0).Item(0) would extract the 1st row and first column value (e.g “baked beans”. How do I modify this expression to get the value from the second column as well? (e,g “baked beans 24p”
Thinking about it, how would I do this so the two values remain in separate columns so I can paste them in to an excel file as two columns?
Fine
you were almost done
it should be like String,Join(“_”,ExtractDatatable.Rows(0).ItemArray)
the output will be like columnvalue1_columnvalue2
in a single step and if we want to paste this in another excel
pass like this ExtractDatatable.Rows(0)(“columnname1”) ExtractDatatable.Rows(0)(“Columnname2”)
Fine no worries
If we have them two assigned values then we can add them to the new datatable using ADD DATA ROW activity
where in the arrayrow property mention like this {variable1,variable2}
and in the datatable mention the datatable variable name
Brilliant, thank you. One last cheeky question please. How do I empty the original data table? Because it is in a For Each loop and I want to empty it ready to search the next item on my shopping list and take the same steps around getting the first value from the data table etc
No worries
use CLEAR DATATABLE activity and pass the datatable so that it will clear all the data and we will be having only the header
Cheers @jordrowley
When I assign my two variables and then use the add data row to add them to my new data table (which I have initialised using ‘New System.Data.DataTable’) I get this error
Please can I ask if you know why I am getting this error? Is it bacause I somehow need to specify that my new initialised data table needs to have two columns in it?
Thanks @sandipauti, the two items I need are in string variables at the moment. Do you know I covert them in to an array so I can then pass that in as a data row?
@jordrowley - Suppose you store first string variable as String1 and second as String2 then you can create third variable arr as array of string and assign the value to variable
Yah certainly, We need to make sure that the number of values passed in the ArrayRow should be equal to the number of columns in our datatable that we have mentioned inthe datatable property of add data row…