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: 1064
Registered: March 2006
Location: Italy
Experienced 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: 889
Registered: December 2006
Experienced 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: Tue Sep 17 14:56:18 CEST 2019

Total time taken to generate the page: 0.01105 seconds