Object reference not set to an instance of an object in add data row

I am trying to use the ‘Add Data Row’ activity within a ‘For Each Row’ in a DataTable activity, but I encountered an error: ‘Add Data Row: Object reference not set to an instance of an object.’ How can I resolve this issue

Hi @Mohammad_Rizwan_03

Did you initialize the data table. use Build DataTable activity to create one DataTable with all required columns and then use Add DataRow activity to add data row to excel file and pass Array row as like below.

{"Value 1","Value 2",......."Value N"}

Regards

Hi @Mohammad_Rizwan_03

Can you try to add
New Object before {} in ArrayRow value

Regards,

I followed the same steps, but I’m still encountering the same error.

Hi @Mohammad_Rizwan_03

It seems some variable is empty, that’s why its throwing an error. Check whether every variable you have used in Add Data row has an value.

Regards

I tried using a new object, but it still isn’t working.

@Mohammad_Rizwan_03,

It’s because your Dt_Final is null.

Thanks,
Ashok :slight_smile:

image

@Mohammad_Rizwan_03,

See the Dt_Final is null that’s why you are getting this error.

A debug window showing local variables where the value of a DataTable variable is null, and several other string variables are listed with their corresponding values. (Captioned by AI)

Thanks,
Ashok :slight_smile:

Hi @Mohammad_Rizwan_03

The screenshot clearly indicates that your datatble is null. Make sure you have passed the variable in Build DataTable activity.

Regards

image

Hi @Mohammad_Rizwan_03

Please place the Build datatable outside For Each row in Datatable activity.

Regards

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