How to add string data in data table

I am facing issue while adding string data in data table. I am using loop eg I am executing loop 5 time store value in string then pass in datatable. for this I am using
1.Build datatable
2.Add datarow
output of this its removing previous value not able to hold all 5 value which I am generating from loop.
Shall anyone help me on this

Hi @Aditya10989 ,

Could you provide a Screenshot of your implementation ? I believe you are using the Build Datatable activity inside the loop, but it should be kept outside the loop.

Do check by keeping the Build Datatable activity outside the loop and confirm if it works as expected.

Hi @Aditya10989

Create Build Datatable activity in the intial process of automation and should be kept outside the loop and Add DataRow after looping for 5 times and storing that in a variable after the loop. Please share the screenshot so that further information can be provided.

Hope it helps!!

Regards,

1 Like


@supermanPunch

yes correct I guess this is the mistake I am doing thanks a lot let me try and update you

1 Like

thanks @supermanPunch @Parvathy its worked. Shall you please guide me how can I remove column header…?

@Aditya10989 ,

We would need to understand what is it that you actually want to perform ?

Do you want to Delete the whole Column ? Do you want to Rename the Column name of the Datatable ?

An Example input and the Expected Output for that Input could help us provide accurate suggestions.

Normally, Renaming of the Column Name in a Datatable can be done in the below way using an Assign activity :

DT.Columns("YourCurrentColumnName").ColumnName = "New Column Name"

@supermanPunch I am getting data with header. But I don’t want header. How can remove header from datatable

@Aditya10989 , Do you want to write the Datatable to an Excel sheet ? Are you using Write Range activity with Add headers checked ? If so, Uncheck the Add Headers option and confirm if you are getting the Output as Expected.

No I am not writing in data table

@Aditya10989 ,

Could you let us know what is your current Datatable value ? When using the Datatable, we will not be able to remove the Headers, but we will be able to remove the whole column or Change the column header names.

Need to understand what is it that you actually mean by the Removal of the headers.

@supermanPunch I am able to remove but I guess this is not best way.I have first convert data table to string then dt.remove(index) then again convert to data table

Hi @Aditya10989

Write the datatable to Output data table and the outlut of the activity is a string type.
Take an assign activity and assign the output of output data table activity to MyDataTableText =

varname(output data table)= MyDataTableText.Remove(0, MyDataTableText.IndexOf(Environment.NewLine)+2)

Hope it helps!!

Regards,