Validation error ---

Hi,

Please can you assist with this validation error I have received,

Error ERROR Validation Error Compiler error(s) encountered processing expression “IIf(string.IsNullOrEmpty(CurrentRow.Item(0).ToString()),0,CurrentRow.Item(0).ToString())”.(2) : error BC30512: Option Strict On disallows implicit conversions from ‘Object’ to ‘String’. Main.xaml

Kind Regards

Hello @Aki1111

can you try this one? replace with these code

IIf(String.IsNullOrEmpty(CType(CurrentRow.Item(0), String)), 0, CType(CurrentRow.Item(0), String))

Best Regard,

why cType if you dont mind me asking for future reference

still the same error.

image

All my variables is of type string

CType is a function used for explicit type conversion between various data types, while ToString is a method for converting an object to its string representation
but both seem similiar to each other but i usually use Ctype for convert.
Note : Correct me if i’m wrong because i’m not sure about use case which one is better.

Sorry for giving wrong solution
can you try this one? i think it should work because i try in my process and not showing error
If(IsDBNull(CurrentRow.Item(0)) OrElse String.IsNullOrEmpty(CurrentRow.Item(0).ToString()), “0”, CurrentRow.Item(0).ToString())

1 Like

Can you please explain what this is telling for future reference? :smiley:, I will let you know if it works.

Yes,

If(IsDBNull(CurrentRow.Item(0)) OrElse String.IsNullOrEmpty(CurrentRow.Item(0).ToString()), “0”, CurrentRow.Item(0).ToString())

Step by Step

  1. CurrentRow.Item(0) Refers to the first item (at index 0) in the CurrentRow object, which is a DataRow from a DataTable. This item type : Object.

  2. IsDBNull(CurrentRow.Item(0)): The IsDBNull function checks if CurrentRow.Item(0) is a DBNull value or not. DBNull represents an uninitialized value or a nonexistent value in a database field. The function returns True if the value is DBNull, and False otherwise.
    Definition :Uninitialized value: A value that hasn’t been assigned or set.
    Nonexistent value: A value that is missing or not present.

and then for OrElse String.IsNullOrEmpty(CurrentRow.Item(0).ToString()) will be else if condition to check if value is null

so if value in object is null (Not “0”) it will get detected by DBNull or String.IsNullOrEmpty condition and then will returned value as “0” but if not will return the exactly value that we retrieved.

1 Like

Received this error

image

Hi @Aki1111 ,

Maybe the correction was to be done by keeping the same type values, difference in 0 and "0":

If(string.IsNullOrEmpty(CurrentRow.Item(0).ToString()),"0",CurrentRow.Item(0).ToString())
1 Like

ah yes so i missed the correction at True condition Value.

Sorry for giving played big solution.

Hi that sorted out the error but Im stuck with the compiler error, that is assign to a variable I put the code in.

Hi @Aki1111,

Since the value returned by CurrentRow.Item(0) is of type Object, the IIf function is throwing an error while trying to convert it to String.

Can you try changing your 0 value to “0” and see if it produces a result?

Regards,
MY

did you try reopen workflow/Studio or check error list if there any error in workflow?

Hi,

I tried that however the error still remained.

error thrown here:

@Aki1111 ,

Could you maybe re-iterate on what is the error that you are currently facing ? Provide a Screenshot if not already provided, If provided do direct us to that screenshot.

This the error:

“Assign: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.”

its coming from the assign block I have re-opened the workflow.

I believe the issue is with the double quotes present in the expression as you might have copy pasted the expression.

Just retype the Expression again or just re-type the Double Quote’s present in it and check.

It is one of the issues that we get when performing a copy paste. It is already recorded and you could find it in the below post :

1 Like

does it mean put them in single quotes?

Solution : Replacing (retyping) all the double quotation to " (0x22) in the expression will solve this matter.