Multiple Assign: Can not assign 'outputDataTble.Rows(0)("Remark").ToString()' to 'Remark'


Issue in the assign, value to save. not able to catch the excel data into the html brows.

@Fel_U,

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:

  1. Check if DataTable is Empty:

    • The error can occur if outputDataTable is empty or does not have any rows.
    • Add a check before the Assign activity to ensure there are rows:
      If outputDataTable IsNot Nothing AndAlso outputDataTable.Rows.Count > 0
      
  2. 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)
      
  3. 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
      
  4. Use Try Catch Block for Error Handling:

    • To handle unexpected errors, wrap the assignment in a Try Catch block:
      Try
          Remark = outputDataTable.Rows(0)("Remark").ToString()
      Catch ex As Exception
          Log Message: "Error: " + ex.Message
          Remark = String.Empty
      End Try
      
  5. Debug with Log Message:

    • Add a Log Message activity before the Assign to check if data exists:
      Log Message: "Row Value: " + outputDataTable.Rows(0)("Remark").ToString()
      
  6. 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.

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! :blush: