List:MySQL++« Previous MessageNext Message »
From:Jim Lynch Date:January 26 2013 10:22pm
Subject:Can't seem to make templates work
View as plain text  
I have looked at this until I'm blue.  I need fresh eyes:

Code:

             string cameraId;

             string tms;

             try {

                 mysqlpp::Connection con (cDBName.c_str (), countryIp.c_str (),
cUsrName.c_str (), cUsrPass.c_str ());

                 Query query = con.query ();

                 string sql = "update cameras set last_image = %0q: where camera_id =
%1:";

                 query << sql;

                 cameraId = node->cameraID;

                 tms = node->datetime;

                 string sqld = "update cameras set last_image = "+tms+" where camera_id =
"+cameraId;

                 cout <<sqld<<endl;

                 SimpleResult reslt = query.execute (tms,cameraId);

                 

             }

             catch (const mysqlpp::Exception & er)

             {

                 cout<< "Mysql error: "<<er.what()<<" for camera
"<<cameraId<<" and date "<<tms<<endl;

             }

Output looks like:

update cameras set last_image = 2013-01-26 22:07:12 where camera_id = 57

Mysql error: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '%0q: where camera_id = %1:'
at line 1 for camera 57 and date 2013-01-26 22:07:12


The update as printed (with inclusion of the ' delimiters around the 
date) works fine in mysql.

Thanks,
Jim.

Thread
Can't seem to make templates workJim Lynch26 Jan
  • Re: Can't seem to make templates workMartin Gallwey26 Jan
    • Re: Can't seem to make templates workJim Lynch26 Jan
  • Re: Can't seem to make templates workWarren Young28 Jan