Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Escape string in MySQL
Escape string in MySQL [message #51820] Sat, 08 June 2019 08:29 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

when executing a sql.Execute() command I have problem if the content of some string has the single quote , ' . Perhaps other characters may give problem. Do we have a method that treat the string preventing error and let the string to be shown correctly?

Thanks,
Luigi
Re: Escape string in MySQL [message #51824 is a reply to message #51820] Sat, 08 June 2019 17:01 Go to previous message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
You shouldn't embed your string into an SQL statement. Use parameters instead. Example (Sqlite):

String oc_name = "Can't do that";	
Sql sel(dbs);
sel.SetStatement("SELECT id FROM lemma WHERE oc_name = ?");
sel.Run(oc_name);

Another useful method to use is Sql::SetParam.


Regards,
Novo
Previous Topic: postgresql mingw
Next Topic: Sqlite join from select
Goto Forum:
  


Current Time: Thu Apr 25 02:16:32 CEST 2024

Total time taken to generate the page: 0.03889 seconds