UiPath Automation Developer Associate v1 — Question 24
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?
Answer options
- A. Assign New System.Data.DataTable = dt_Reports.
- B. Assign dt_Reports = New System.Data.DataRow.
- C. Assign dt_Reports = New System.Data.DataTable.
- D. Assign dt_Reports = New List(Of DataRow).
Correct answer: C
Explanation
The correct answer is C because initializing 'dt_Reports' as a new instance of System.Data.DataTable ensures that the data table is ready to accept new rows. Option A is incorrect because it tries to assign a new DataTable to an already declared variable without proper initialization. Option B is wrong since it attempts to create a DataRow instead of a DataTable. Option D is also incorrect as it initializes a List of DataRow, which is not suitable for the Add Data Row activity.