SAPHIR - Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add special characters in querys?

Hi. I'm using GDatabase to write data to a MySQL server. The project is in Sweden and I would like to be able to write swedish letters å,ä and ö, but that gives me the following error:

<Error from MySQL server>Incorrect string value: '\xE5 defa...' for column 'Title' at row 1

in MySQLVIEW.lvlib:MySQLConnector.lvclass:Insert.vi:700001->testsweletters.vi->test.vi->

I managed to create the query by doing following: I sent an empty MySQL reference into the "Insert query" and this generated the query before returning the error:

Error:

Dequeue Element in Acquire Semaphore.vi:3480001->MySQLVIEW.lvlib:MySQLConnector.lvclass:Insert.vi:700001->Write New Measurement v2 no datacluster.vi

Query:

INSERT INTO `measurement` (Text, Title, UserID, TimeStart) VALUES ("default text", "ÅÄÖ", 9, "2016/11/04 13:28:00.297981");

The query itself is perfect and understood by the MySQL server, but I can't seem to send it through the GDatabase library. Is there a possible workaround?

Kind Regards,

Jonatan Tidare

0 Kudos
Message 1 of 3
(4,968 Views)

Hi Jonatan,

I think you have to convert your "LabVIEW String" to a UTF8 encoded string by using the "Convert string to UTF8" VI (You will find this VI in GDatabase for MySQL palette -> Utility).

Example :

MySQL_SwedishLetters.png

When you get back data from MySQL server you could have to convert UTF8 encoded String to a "LabVIEW String" by using the "Convert UTF8 to String" VI.

I hope this will work, please let me know,

Regards,

Yannis RICHARD

Message 2 of 3
(4,902 Views)

It works! Thank you. I was looking for options in the Insert block itself, but now it works. Thank you for the fast response.

Kind Regards,

Jonatan Tidare

0 Kudos
Message 3 of 3
(4,902 Views)