prepare functions fails.
Solved
General and Desktop
-
Hello all;
I have this prepare function that refuses to co-operate, any help
I have been reading docs and websites all day .... even tried my son for help.the code is::
test1 = qry.prepare("INSERT INTO histories (datum, hsname, dist)" " VALUES (:histStr[1], :histStr[0], :histInt[0])");
qry.bindValue(":datum", histStr[1]);
qry.bindValue(":hsname", histStr[0]);
qry.bindValue(":dist", histInt[0]);where test1 is a bool that remains false.
Regards.
Frik Brits -
Hi and welcome to the forums
The last part looks odd
" VALUES (:histStr[1], :histStr[0], :histInt[0])");
You should use the bind variable names and not real variable name ( the var where values in )QSqlQuery query; query.prepare("INSERT INTO person (id, forename, surname) VALUES (:id, :forename, :surname)"); query.bindValue(":id", 1001); query.bindValue(":forename", "Bart"); query.bindValue(":surname", "Simpson"); query.exec();