LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database query of unicode string returns Ascii

Solved!
Go to solution

Hello,

 

I'm trying to query nVarchar (Unicode) from SQL Server 2008 using DB Toolkit, but it seems that the result is Varchar (Ascii).

 

The string contains Δ (Delta) but I receive ? (Question Mark) I've used Arial Unicode MS and configured Labview.ini to allow Unicode UseUnicode=True

 

I've also tried forcing the query to Convert or Cast to nVarchar but didn't make any difference.

 

Any idea what the DB Toolkit is doing? I've tried the Select and Execute Vis but no difference.

 

I probed the Variant returned from the query and it contains ? instead of Delta

 

Best Regards,

0 Kudos
Message 1 of 7
(5,411 Views)

There is a Document on NI Database Connectivity Toolkit:L http://www.ni.com/pdf/manuals/321525c.pdf

 

It seems that String/Path is Mapped as Varchar Only. So, what's the workaround to query Unicode String?

 

 

0 Kudos
Message 2 of 7
(5,392 Views)

Does anybody know how to Query database using Activex other than using the Database Connectity toolkit which is pretty much the same thing?

 

I need my query string results to be in Unicode not just Default Labview String (Ascii?)

 

Thanks,

0 Kudos
Message 3 of 7
(5,386 Views)
Solution
Accepted by topic author Tiger81

It has been two years since we tried to query a Unicode string from a database, but at that time the Database Connectivity toolkit was completely incapable of returning a Unicode (UTF-8, UTF-16...) string. A colleague was forced to write some external functions in a DLL that queried the database.

 

I don't know if the Database Connectivity toolkit still suffers from the inability to use Unicode, but since then I have also had success using Postgres and MySQL Connectors with .NET.

 

Another option might be to use BLOB instead of VARCHAR fields.

 

I only have moderate experience with this topic, so you may find a better solution.

Message 4 of 7
(5,378 Views)

Thanks Jack,

 

I ended up using .NET System.Data (OLEDB) to query the nVarchar (Unicode String) from database and loaded a DataGridView placed in a .NET Container. I verified and it returned the proper characters.

 

 

0 Kudos
Message 5 of 7
(5,369 Views)

Just to add that I was able to get the Proper encoding displayed in the DataGridView, however when I use toString method to convert the DataSet to String Array, same thing happens again and the results are shown in ASCII

0 Kudos
Message 6 of 7
(5,344 Views)

I solved by forcing the query to CAST the nvarchar field as BINARY.

i.e. use the query command SELECT CAST(fieldname AS BINARY) FROM table to retrieve the correct UT16-LE byte array  and so read the correct unicode string saved in nvarchar field.

Configure Labview.ini to allow Unicode UseUnicode=TrueEnable and enable the property of the string control: 'Interpret as Unicode'.

See the bitmap for an example..

Message 7 of 7
(3,651 Views)