Hello,
I am trying to make this statement work in SOCI:
//_session previously initialized
string name = "a";
int ID;
statement st = (_session->prepare << "SELECT table.id FROM table WHERE
table.name LIKE '%:name%'", use (name), into (ID));
The above code doesn't work and an exception is thrown. The problem is %:name%.
It looks like SOCI is unable to replace it with the variable name while
preparing the statement.
The only solution I've found that works is:
string name = "a";
statement st = (_session->prepare << "SELECT table.id FROM table WHERE
table.name LIKE '%" << name << "%'", into (ID));
The only problem is that by using streams it does not escape special characters
like '. If I use name = "Tick'Tick'''" It will throw an exception.
How can I make the first example work?
How can escape strings to work with SQL in C++?
Thanks.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users