Problem with Text Field

cnicolapc

Active Member
Licensed User
Longtime User
Hi,

I have a problem with text fields in a SQL database.

When in a text field of a SQL Databse insert the apostrophe me an error sintax.
Example: If a text field called TITLE Enter VENT'ANNI generates error sintax while if I enter VENT ANNI no generates error
It happens both with INSERT and UPDATE.
How can I solve this problem.
Thanks in advance
Nicola
 

glook

Member
Licensed User
Longtime User
In a regular SQLite INSERT or UPDATE you can escape a single quote by adding another one.

Or if you are able to use a "parameter" insert, as it is possible with B4A, then you do not need to worry - the single quote will be accepted.

sql.ExecNonQuery2(INSERT INTO mytable VALUES (?,?), Array as Object(data1,data2))

The single quote escape way is for SQLite in any language. I sometimes write a little subroutine to replace all single quotes with 2 single quotes and then wrap the string with a quote at each end, ready for SQLite.
 
Last edited:
Upvote 0
D

Deleted member 103

Guest
Ciao Nicola,

prova questo:
try this:

PHP:
dim ventanni as string
ventanni="VENT'ANNI"

ventanni=ventanni.Replace("'","''")

L'apostrofo si deve raddoppiare.
The apostrophe should be doubled.

Ciao,
Filippo
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…