LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Variant To Data" fails to convert a variant to I32.

Solved!
Go to solution

labview_variant.png

 

I read an integer from a database which was returned as a variant.

 

The value is 25, but if the VI converts it to I32, the returned value is 0.

 

Why does it happen? How can I fix it?

0 Kudos
Message 1 of 14
(4,198 Views)

Hm, i would say that you have an issue with the numeric value in the variant, not with the cast.

Attached you find a VI combining different numeric data types for casting but i always received the expected value.

 

Are you sure that "Variant To Data" does not return an error? Have you already probed the variant to check if it contains the expected values?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 14
(4,194 Views)

here's a snippet that return the type of data contained in a variant.

 

Example_VI_BD.png

 

hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 3 of 14
(4,189 Views)

@Norbert_B wrote:

Hm, i would say that you have an issue with the numeric value in the variant, not with the cast.

Attached you find a VI combining different numeric data types for casting but i always received the expected value.

 

Are you sure that "Variant To Data" does not return an error? Have you already probed the variant to check if it contains the expected values?

 

Norbert


I see
Error -2147467261 : ConvertDBDataToNmtData[V.01].vi->Impl_ReadNMTFromAccessDB[V.02].vi "Wrong Pointer"

LabVIEW:  (Hex 0x80004003) Invalid Pointer.

 

This error happens when "Variant To Data" tries to convert a variant matching DB NULL value to another type.

 

How do I check a NULL value?

0 Kudos
Message 4 of 14
(4,188 Views)

What is the version of LV you are using?

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 14
(4,183 Views)

2009 SP1

0 Kudos
Message 6 of 14
(4,181 Views)

Can you look into MAX and find out which version of the Database Connectivity Toolkit you have?

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 14
(4,172 Views)
Solution
Accepted by topic author iCat

@iCat wrote:

 

The value is 25, but if the VI converts it to I32, the returned value is 0.

 


Try to use Database Variant To Data instead of Variant To Data:

 

db.png

0 Kudos
Message 8 of 14
(4,163 Views)

@TiTou wrote:

here's a snippet that return the type of data contained in a variant.

 

Example_VI_BD.png

 

hope this helps


this doesn't help?


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 9 of 14
(4,160 Views)

@TiTou wrote:

@TiTou wrote:

here's a snippet that return the type of data contained in a variant.

 

Example_VI_BD.png

 

hope this helps


this doesn't help?



Since I'm a LabVIEW beginner, I don't know what that even means.

0 Kudos
Message 10 of 14
(4,135 Views)