Hi, because of some complexity in my project, I am using VB.net for a part of my robot (Invoke Code).
With this line, I want to add a column to a data table:
out_dt_TruckAssembling is a data table given as an ‘Out’ argument for Invoke Code.
But at runtime, it gives this error:
Am I wrong in use of the argument?
Can you try to add the following at the beginning of the code?
out_dt_TruckAssembling = New DataTable()
we can do the same within an Assign Activity and avoid the black box code activity
myCol = YourOriginDatTableVar.Columns.Add(“testcol”, GetType(Integer))
otherwise ensure that out_dt_TruckAssembling is initialized with a new DataTable() within the invoke code
We can also use Invoke Method for adding columns:
DataTable.Columns (“ColumnName”)) MethodName (SetOrdinal)
Same thing you can do it in your Vb code as well: to add a column
This does not work.
But I’ve found a workaround after your suggestion.
- Dim dt as New Datatable
- Do some things with dt (add columns etc…)
- out_dt_TruckAssembling = dt
After that, the argument is loaded in variable dt_TruckAssembling.
For information: imo, the code is to complex to do it all with UiPath activities. Coding it in VB.net makes it more clear.
It means out_dt_TruckAssembling hasn’t been initialized. It’s “nothing”
I think we can directly create instance for out_dt_TruckAssembling as the following sample. Can you try this?
Sample20230610-1a.zip (2.5 KB)
You could have initialized the datatable as well, New System.Data.Datatable.
But as mentioned in my first question, I need do program it in Invoke code. It is really dynamic.
Thank you, Yoichi. It works now.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.