Using QSqlQuery bindValue()
Hi,
I’ve just started using Qt 4.6. I have the following code:
- {
- // Get user from database.
- "where username = :username";
- QSqlQuery query;
- if (false == query.prepare(sql)) {
- qDebug("Failed to prepare query.");
- return 0;
- }
- query.bindValue("username", username);
- ...
- }
However, it does not compile:
error C2664: ‘void QSqlQuery::bindValue(const QString &,const QVariant &,QSql::ParamType)’ : cannot convert parameter 2 from ‘QString’ to ‘const QVariant &’
I must be missing something very obvious. Do I have to manually convert the QString to QVariant? How do I do that?
Thanks!
3 replies
You must log in to post a reply. Not a member yet? Register here!



