I am getting an error invalid operands of types const char [42] and double to binary ‘operator+’

Well, in C++ you can’t concatenante strings with other types like it would be done in Javascript.
You need to tranform you variables in strings and then concatenate all of theses.

My solution uses stringstreams, wich have the operators defined to push various native types into the stream. Then you can just get the final string from the stream.

std::ostringstream update_cmd;

update_cmd << "UPDATE cropdatabase1 SET CropLatitude="";
update_cmd << latitude;
update_cmd << "", CropLongitude="";
update_cmd << longitude;
update_cmd << "", SownDate="";
update_cmd << SownDate;
update_cmd << "", Status="1",Where UNC = '";
update_cmd << unc;

QSqlQuery update_values;
update_values.prepare(update_cmd.str());
update_values.exec();

Leave a Comment