This would be happening when the Remark is blank or null
Use this expression to assign Remark
If(outputDataTble.Rows(0)("Remark") Is DBNull.Value,"",outputDataTble.Rows(0)("Remark").ToString())
Hey @Fel_U,
The error “Cannot assign ‘outputDataTable.Rows(0)(“Remark”).ToString()’ to ‘Remark’” typically means there’s an issue with retrieving or assigning data from the DataTable. Here are some potential reasons and solutions:
Possible Causes and Solutions:
-
Check if DataTable is Empty:
- The error can occur if
outputDataTableis empty or does not have any rows. - Add a check before the
Assignactivity to ensure there are rows:If outputDataTable IsNot Nothing AndAlso outputDataTable.Rows.Count > 0
- The error can occur if
-
Use Default Value for Null or Empty Cells:
- If the “Remark” column is empty or null, use a conditional operator to handle it:
Remark = If(outputDataTable.Rows(0)("Remark") IsNot DBNull.Value, outputDataTable.Rows(0)("Remark").ToString(), String.Empty)
- If the “Remark” column is empty or null, use a conditional operator to handle it:
-
Verify Column Name (“Remark”):
- Ensure that the column name “Remark” exists in your DataTable. It could be case-sensitive or have extra spaces.
- Use
outputDataTable.Columns.Contains("Remark")to verify:If outputDataTable.Columns.Contains("Remark") Remark = outputDataTable.Rows(0)("Remark").ToString() End If
-
Use Try Catch Block for Error Handling:
- To handle unexpected errors, wrap the assignment in a
Try Catchblock:Try Remark = outputDataTable.Rows(0)("Remark").ToString() Catch ex As Exception Log Message: "Error: " + ex.Message Remark = String.Empty End Try
- To handle unexpected errors, wrap the assignment in a
-
Debug with Log Message:
- Add a
Log Messageactivity before theAssignto check if data exists:Log Message: "Row Value: " + outputDataTable.Rows(0)("Remark").ToString()
- Add a
-
Ensure Data Extraction from Excel is Correct:
- Double-check your Read Range or Excel activities to make sure data is being read correctly into
outputDataTable.
- Double-check your Read Range or Excel activities to make sure data is being read correctly into
Summary of Updated Assign Activity:
Remark = If(outputDataTable IsNot Nothing AndAlso outputDataTable.Rows.Count > 0 AndAlso outputDataTable.Columns.Contains("Remark"), outputDataTable.Rows(0)("Remark").ToString(), String.Empty)
Try implementing these solutions and let me know if it resolves your issue! ![]()
