Object reference not set to instance of an object - please help

I’m new to Ui Path and am receiving the below error message when try to Add Data Row as an activity. I’ve looked it up in other forum topics, but I haven’t come across a fix that works. Can anyone help me please?

I’m trying to manipulate/extract excel file columns.

Dayton Kendrick


Welcome to the UIpath Community.

This error generally occurs when we are trying to assign null value. Please check whether you passed data properly or not.

To add to what @lakshman said, one of your variables has no value.

So either “row” or “Asiadt” have not yet been initialized. This means that one or both are created but have not yet been given a value of any kind. Check to make sure that you are assigning both of these a value at some point prior to the Add Data Row activity.

1 Like

Thanks for the tips Daniel, here’s what I have before the Data Row activity.

You have to initiate your Datatables first


This would seem to indicate to me that Asiadt is not initialized. You should set its “Default” value equal to “new System.Data.DataTable” or use an Assign activity to set it equal to “new System.Data.DataTable”.

Creating a variable is the equivalent of saying “I’m going to need this at some point, I’ll tell you what value it has later.” So when you try to add a row to the table later the computer freaks out because you haven’t yet told it what values (if any) the table should start with. When you tell it to use new System.Data.DataTable you’re saying “This datatable doesn’t yet exist, please give me a new one.”

1 Like

Hi @dkendrick1

Welcome to UiPath community buddy
First let me tell you why this occurs, as the message states, when any object say any variable in the ACTIVITY that shows this error has no value in it, or the variable assigned with another variable which doesn’t have any value in it… Will lead to this error…

So here in your ACTIVITY add data row there are two variables been used…

Where row comes from a for each row loop, and Asiadt is a datatable variable…
So we need to check whether any of these variables has null value…
row - Check whether any of the column value along the row is empty…check with writeline activity by passing the value like row(0).ToString
…like wise for all columns where 0,1,2,… Represents the column index… ( this step is done only to check whether there is null value ) not necessary if the valu with them

Asiadt - make sure you have a structure defined for this datatable with similar columnname of the table from where you are getting value…to create a similar structure of datatable say indt which is the datatable you are passing as input to for each row loop, but before for each Row loop we need to place a assign activity like this
Asiadt = indt.Clone
This will create similar structure of the datatable you pass to the for each row loop…
And after this Assign activity
Use a clear datatable activity and pass input as Asiadt which will clear the rows and will have only datatable structure…only column names…
Now use the for each row loop and use add datarow activity …it will work for sure…
Kindly try this and let know whether this works or not
Cheers @dkendrick1


once I added new System.Data.DataTable I received the following error:

  1. List item

This stack overflow thread has a solution, we just have to work it into UiPath. When a row is in a datatable it is “owned” by that table so we cannot simply copy it.

Use the Invoke Method activity with the following settings:
TargetType: (null)
TargetObject: Asiadt.Rows
MethodName: Add

Then on the Parameters property add a parameter as follows:
Direction: In
Type: Object
Value: row.ItemArray

All together this will add a copy of the row to the Asiadt DataTable. It does so by using the values given in the rows ItemArray property, which are just the values of the row in an array.

pass them as array row @dkendrick1
we have a property called array row in add data row activity
there pass the value as array within {value1,value2,value3,… }
that would work for sure
Cheers @dkendrick1

Invoke importrow instead of add. This should work.


I did what you suggested and it worked, but yielded an Array column error. Sorry for all the issues, but still at a novice stage…

  1. List item
1 Like

how many columns are there and how many rows are there buddy
the number should match between them…
i think it didn’t match thats why throwing this error
You were almost done…check the number value passed in array row property of add data row which must be same to that of number of columns in your table
Cheers @dkendrick1

1 Like

@dkendrick1 put a Build Data Table activity at the top of your workflow before you loop and add DataRow. Build the columns so that they match the DataRow you are trying to add.

Let’s say your DataRow columns are String,Int,String,String. Then your Build Data Table activity would look like:

1 Like

Got it to work!!! Thank you so much; made a couple other tweaks but I’m in business.

Thanks again!


Thats great
Cheers @dkendrick1


i am using http activity to extract data from a web service . then i have used deserialize json array activity . after that i need to export the entire data in data table . there i have used build data table activity with 4 columns then i have used add data row activity where my workflow is throwing error : Object reference not set to instance of an object in add data row activity . Please help me out with this.

Hi, this can help you
Within the read range don’t leave space in between double quotes,i got the above error because of space between the double quotes


Could you please be more clear?
Don’t use space between double quote or you can remove it as well.