Add Data Row Error - Object reference not set to an instance of an object


Kind of common error but stuck because of this.I have 8 column in a datatable, I need to add the datarow using array. But doing this gives the error. Is it because some of the values are null?

How to get these null value replace at once so that this error doesn’t occur?

Below is the Local Variable value of the array in debug mode when the erroe occurs:

string[8] { "\ “06/16/2020”, “MyName”, “AAA”, “System.String[]”, null, “”, null, null}

Any solution to this?

check in Debug mode / set Breakpoint within the locals panel if datatable is set


Thanks for the reply, just checked its showing null for data table in the locals panel so that’s not initialized.

I’ve used Build Data Table to created the instance for that datatable and just mentioned headers there.

So I believe, I need to add the first dummy row and then delete it later.

Can we intiliaze the datatable without entering ya dummy row? or any other solution?

there is no need for dummy row, would also more disturb as help.
Check variable scope,
check if no duplicate variable name exists,
check if no argment withthe name exists

No duplicate variable and two arguments are just null including the datatable itself.

how can we resolve this without a dummy row?

I do often use build datatable for constructing schemas and instead of adding a dummy row i do clear the dt to ensure that there is no blank row inside.

Can you share your xaml. I would have a look on it

Issues was a silly mistake related to providing the correct argument. :sweat_smile: It’s Resolved now

Thanks @ppr for the reply and help.

Can’t delete the thread, so marking the solution to close the topic

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