On 7/13/2011 2:04 PM, Jay Sprenkle wrote:
>
> mysqlpp::Query query = conn.query( "UPDATE customer SET
> AccountName=%2q, Active=%3, Password=%1 WHERE CustomerId=%0" );
> query.parse();
> mysqlpp::SQLQueryParms parms;
> ....noise noise noise...
Why are you bothering with direct use of SQLQueryParms? This does the
same thing, with less code:
mysqlpp::SimpleResult res = query.execute(
mysqlpp::sql_int(CustomerId),
mysqlpp::sql_blob(data, sizeof(data)),
...etc...);
> If I turn off exceptions for the connection it fails silently (the
> result.info() method returns nothing).
That just gets you "additional information". To check for errors, test
res in bool context instead:
if (res) {
// query was successful
}
else {
// FAIL
}
> if I turn exceptions on it seg faults here when trying to convert to a
> string:
You need to quote and escape BLOBs. Your binary password is being
inserted into the query string raw, as-is.
Consider using SSQLSes instead of template queries. It handles quoting
and escaping for you automatically.