Home > Back-end >  Could not convert variant of type (null) into type (Boolean)
Could not convert variant of type (null) into type (Boolean)

Time:09-17

Could not convert variant of type (null) into type (Boolean) how to solve

CodePudding user response:

Should be the Null type, the Boolean type conversion, error-prone,
Find the original code error sources,

CodePudding user response:

When operation XML attributes, if there is no corresponding attributes, such as: bFlag:=Node. Atrributes [' ABC ']
Will encounter this error, the main reason, is lazy, direct use of the variant type assignment, but the variant sometimes empty, will lead to errors

CodePudding user response:

Assign the value of the Boolean type is empty

CodePudding user response:

You have the code?

CodePudding user response:

In SQL using ISNULL function all
ISNULL (FieldName, ReturnNullDefVal ReturnNotNullDefVal)

In Delphi, a custom IIF function
The function the IIF (BoolenExpress: Boolean; ReturnTrueValue ReturnFalseValue: Varaint) : Varaintl
The begin
IF a Boolean THEN Result:=ReturnTrueValue
The ELSE
Result:=ReturnFalseValue;
end;

CodePudding user response:

Take less than the value, or a null value is empty, you can add a judgment to avoid empty
  • Related