(Add Data Row)Object reference not set to an instance of an object

I’m currently performing Excel operations. I’ve successfully executed the “Join DataTable” operation and applied an “If” condition. However, I’m encountering an error when attempting to add a data row to the DataTable.

1 Like

Hi @chandrakala.productanalys ,
Can you share input and expect output
or
your image about your activity and error?
regards,

Hello @chandrakala.productanalys

  1. Ensure column names and data types match.
  2. Check for null values and column constraints.
  3. Verify the destination DataTable is valid and not empty.
  4. Avoid concurrent access to the same DataTable.
  5. Double-check the activity configuration.
  6. Implement error handling to capture and address exceptions.

Thanks & Cheers!!!

Hi @chandrakala.productanalys

Check if the data row you’re trying to add is properly initialized and contains data. If the data row is null or empty, you will encounter this error. And the data row should be an array of objects matching the schema of the DataTable.

1 Like

can you check that dt_newdatatable variable scope

@chandrakala.productanalys

yes.Within Scope only.

It may happen if datatable has empty rows

make sure that dt_newdatatable variable has been properly initialized before starting the add data row

if it initialized then can you debug and check that it has having rows or not

@chandrakala.productanalys

debug and check what u find in dt_newdataTable

1 Like

Rows containing '-- values will be considered as empty rows in the DataTable

@chandrakala.productanalys

Check all the values in the arrow row that you are passing is not empty and the length of the array row must be equal to columns length of the datatable. And you should have used an activity like “Build DataTable” or “Read Range” to create the DataTable before attempting to add a row to it.

If all are perfect but not working then use multi assign activity to store the current row values in separate variables then pass those variable in the add data row activity.

Can you try with
new object before {} in array row value

Hope it helps

Rows containing ‘–’ values will not automatically be considered as empty rows in a DataTable.
@chandrakala.productanalys

By using Build data table activity

You can try this method but it might be lengthy :point_down:

  1. first create a new row for your datatable

  2. Add values to your row

  3. Add that row to datatable
    Capture3

Check that the no. of columns in the build datatable must be equal to the array row length in the data row activity. And give the values length as -1 (max length) for every column in the build datatable activity to avoid the string length issues.
@chandrakala.productanalys

1 Like