A developer utilized the Add Data Row activity to insert a row into a data table called "dt_Reports". However, during runtime, UiPath Studio encounters an exception, "Add Data Row: Object reference not set to an instance of an object." because the data table has not been initialized. To rectify this issue, what should the developer include in an Assign before the Add Data Row activity?
Select an option, then click Submit answer.
Reference / correct answer:
Assign dt_Reports = New System.Data.DataTable.
Most accepted answer: C. Assign dt_Reports = New System.Data.DataTable.
Community votes: C=2
Selected Answer: C Correct answer is C upvoted 1 times
Selected Answer: C Data table need to be initialized before use. If dt_reports is not initialized attempting to add a row will cause a null reference exception. Only option C is correctly initializing. upvoted 1 times
To rectify the issue of the data table not being initialized, the developer should initialize the data table before using the Add Data Row activity. The correct assignment would be: Assign dt_Reports = New System.Data.DataTable This initializes the data table, ensuring it is ready to have rows added to it. Therefore, C (Assign dt_Reports = New System.Data.DataTable) is the correct answer. upvoted 1 times