Is there a difference between BindValue
and QString.arg()
database wise?
QString().arg()
:
QSqlQuery qry;
qry.prepare(QString("INSERT INTO employee (id, name, salary) VALUES (%1, 'Thad Beaumont', %2)").arg(1001).arg(65000));
qry.exec();
QSqlQuery::bindValue
:
QSqlQuery query;
query.prepare("INSERT INTO employee (id, name, salary) VALUES (:id, :name,:salary)");
query.bindValue(":id", 1001);
query.bindValue(":name", "Thad Beaumont");
query.bindValue(":salary", 65000);
query.exec();
Is there any performance difference between them? Is BindValues
preferred over the other method?