LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way of stopping labview from autoconverting hex data from an SQL database to ascii?

Solved!
Go to solution

Aha! Thank you sir. That might indeed be the problem I'm having.


SQL server is showing me the information as a hex code of 2048 characters (hence one reason I didn't display the entire data string). I originally copied the data to my test "Convert this to usable data" code and it pasted as the hex (expected I suppose). I'll try forcing it to a byte array and working with that. I'll have to rewrite my code (because it was converting the string to a byte array and then to what I needed anyway).

Note: Yes, doing the testing by pasting the string was intelligent at the time as I didn't have SQL on my computer when I was originally writing the conversion tool.

Anyways, thank you again. Stupid little misunderstanding on my part, and I appreciate the help immensely.

0 Kudos
Message 11 of 16
(873 Views)
If you don't want the data to show up as ascii don't connect the output directly to a string indicator. Or change the display mode is the string indicator to hex.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 12 of 16
(870 Views)

That's the thing. Even with it in hex display, it was wrong.

I think the other suggestion will work, I just have to switch my code around and not use the fetch/query database functions as those don't like converting straight to byte array for some reason.

0 Kudos
Message 13 of 16
(861 Views)

Actually, what I suggested will work...it just needed an additional parameter.  Use this in your select statement.

 

CONVERT(varchar(max), db_binary_field_name, 1)

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 14 of 16
(856 Views)

I'll give that a try as well at some point. I'm sure I'll have to trim down my code a bit later, so that may be useful. Taking my data as a byte array definitely works (just tested it).

0 Kudos
Message 15 of 16
(844 Views)

OK but it doesn't require any post processing on the data.  With a 1 as the last parameter, the value returned is the hex data (as a string) with the '0x' prefix.  With a 2 as the last parameter, the '0x' is removed.  

 

I am using MSSQL.  I'm not sure if other versions of SQL support this function or not.  When working with databases, I'm always looking for ways to offload some of the work to the server so that I get the data back exactly how I want it.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 16 of 16
(836 Views)