juliano.gomes
27th November 2015, 20:06
Hello,
I'm with problem in my UPDATE clause using placeholder (https://www.sqlite.org/lang_expr.html#varparam) (sqlite3). In some fields the placeholder return a incorrect data, even i verifying that the data that i send to UPDATE is correct.
Eg:the output from "query2.value(0).toInt()" is 2 (a integer value, like i expected), but the placeholder ":id_city" stores the following value: 1_city
QSqlDatabase con = QSqlDatabase::addDatabase("QSQLITE");
con.setDatabaseName(_DB);
con.open();
QSqlQuery query;
// the problem occur ins some cases with different data types, like integer directly (0), query2 return and text from qlineedit, as with diferent object types (qlineedit, qcombobox, qcheckbox)
query.prepare("UPDATE table SET id_country=:id_country, id_city=:id_city, name=:name ...... WHERE id=:id"
query.bindValue(":id_country",1);
query.bindValue(":id_city",query2.value(0).toInt());
query.bindValue(":name",ui->QLineedit->text());
.
.
.
query.bindValue(":id",_ID);
query.exec();
someone known where is the problem? could help me please?
Thanks!
Juliano
I'm with problem in my UPDATE clause using placeholder (https://www.sqlite.org/lang_expr.html#varparam) (sqlite3). In some fields the placeholder return a incorrect data, even i verifying that the data that i send to UPDATE is correct.
Eg:the output from "query2.value(0).toInt()" is 2 (a integer value, like i expected), but the placeholder ":id_city" stores the following value: 1_city
QSqlDatabase con = QSqlDatabase::addDatabase("QSQLITE");
con.setDatabaseName(_DB);
con.open();
QSqlQuery query;
// the problem occur ins some cases with different data types, like integer directly (0), query2 return and text from qlineedit, as with diferent object types (qlineedit, qcombobox, qcheckbox)
query.prepare("UPDATE table SET id_country=:id_country, id_city=:id_city, name=:name ...... WHERE id=:id"
query.bindValue(":id_country",1);
query.bindValue(":id_city",query2.value(0).toInt());
query.bindValue(":name",ui->QLineedit->text());
.
.
.
query.bindValue(":id",_ID);
query.exec();
someone known where is the problem? could help me please?
Thanks!
Juliano