LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle special characters in SQL statements

How do you handle special charactes in a SQL statement? Here is an example:
 
update table
set notefield = 'This is Waldo's note'
where keyfield = 7;
 
Because the database connectivity vi accepts a string datatype wire, the ' in Waldo's note is seen as the end of string and an error is generated.
 
Is there a way to tell labview that the ' is part of the string and not the string delimiter?
 
Waldo
0 Kudos
Message 1 of 6
(19,030 Views)
Hi Waldo,

I admit this is a little bit of a guess but have you tried doubling up the apostrophe? I think SQL will realize that two apostrophes next to one another is to be treated as one apostrophe. For example 'This is Waldo''s note'

I will cross my fingers on this one.

Cheers,

--Russ


Message 2 of 6
(19,026 Views)

If two single quotes don't work, try backslash single quote, like \'

The backslash is often used as an escape character, meaning to treat the next character literally.

- tbob

Inventor of the WORM Global
Message 3 of 6
(19,011 Views)

Russ,

It works! Thanks for the info

 

Waldo

0 Kudos
Message 4 of 6
(19,006 Views)

I have the same problem with an with a string with "é".

After insert "e" become "?".

Could you help me.

0 Kudos
Message 5 of 6
(3,167 Views)

That’s an encoding problem and totally different from the original problem. LabVIEW uses ANSI strings which use whatever codepage your system is configured with. Depending on your database driver he may convert such strings to Unicode on your computer in which case there is no problem. But many just send the binary codes for the ASCII characters and then the database has to guess what codepage they were in which is of course s hopeless exercise and it just uses whatever codepage its own computer is set. For some databases or specific tables you can set the codepage to use and sometimes a database driver allows explicit configuration but each database uses it’s own options here, and sometimes even different drivers for the same database backend are inconsistent.

 

 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 6
(3,142 Views)