Parameter count mismatch in Qtsql
<p>I'm trying to insert data into a QtSql database, but I keep getting the error:</p>

<pre><code>"Parameter count mismatch"
</code></pre>

<p>What could be what I'm doing wrong?</p>

<pre><code>#include &lt;QtSql&gt;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    qDebug() &lt;&lt; QSqlDatabase::drivers();

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setHostName("LOCALHOST");
    db.setDatabaseName("people");
    db.setUserName("root");
    db.setPassword("");

    if(db.open()) {
        qDebug() &lt;&lt; "Opened!";

        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();

        if( !query.exec() )
            qDebug() &lt;&lt; query.lastError().text();
        else
            qDebug( "Inserted!" );

        db.close();

    } else {
        qDebug() &lt;&lt; "Not opened";
    }
}
</code></pre>