Hi everyone,

i'm trying to execute sql command, but everytime i get an error "Parameter count mismatch".
Looking other examples i think that sql syntax is ok. Maybe i'm wrong, that's why i'm asking your help
Please, can someone tell what is wrong with code?

This is the code:

Qt Code:
  1. QSqlQuery query;
  2. QString strQ = "INSERT INTO item(dict_id, word, prefix, translated, audioPath, example, pronunciation, wordtype, synonyms) VALUES(?,?,?,?,NULL,?,?,?,?)";
  3. qDebug() <<"PREPARE: " << query.prepare(strQ);
  4. query.bindValue(0, QVariant(_dictID));
  5. query.bindValue(1, QVariant(word));
  6. query.bindValue(2, QVariant(clan));
  7. query.bindValue(3, QVariant(translated));
  8. query.bindValue(4, QVariant(example));
  9. query.bindValue(5, QVariant(pronun));
  10. query.bindValue(6, QVariant(wordType));
  11. query.bindValue(7, QVariant(synonym));
  12. if(query.exec(strQ))
  13. {
  14. qDebug() << "Query exec YES";
  15. MyMessageBox mb;
  16. mb.setStyleSheet("background-color:white; color:black;");
  17. mb.setText("A new word is added: " + word);
  18. mb.setIconPixmap(QPixmap(":111.png"));
  19. mb.setStandardButtons(QMessageBox::Ok);
  20. mb.setAutoClose(true);
  21. mb.setTimeOut(2);
  22. mb.exec();
  23. }
  24. else
  25. {
  26. QMessageBox::warning(this, "Adding of word ", "A new word is not added",QMessageBox::Ok);
  27. qDebug()<<query.lastError().text() << query.boundValues().count();
  28. }
To copy to clipboard, switch view to plain text mode 


And this is output:

PREPARE: true
" Parameter count mismatch" 0



Thx a lot for any suggestion