How do I write a variable to a datatable

I need to write a string variable to a to go in a specific place in the datatable. Im using the following:

Assign
Datatable(1)(0) = Variable
Actual code is = DT_Collector(PCAPDocNum-1)(0) = InvestorNameOutput

I am getting the following error message:
Assign: Cannot create an L-value from the given expression with property ‘set_Item’ because the target object is null.

1 Like

Fine the expression would be like this
Yourdatatable.Rows(rowindex)(columnindex) = variable.ToString

Where both rowindex and columnindex starts from 0 for the first row and first column

So it would be like this
Yourdatatable.Rows(1)(0) = variable.ToString

Or we can even mention the column name if we know
Yourdatatable.Rows(rowindex)(“columnname”) = variable.ToString

Cheers @Michael_Pansolini

1 Like

Hi,

I suppose your PCAPDocNum is greater than DT_Collector.rows.count.
Can you check it using the following WriteLine activity before the Assign.
PCAPDocNum.toString + ":" + DT_Collector.rows.count.toString

Regards,

Hi @Michael_Pansolini
I think this issue has been resolved.Kindly see article below for your reference.

cheers :smiley:

Happy learning :smiley:

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