Results 1 to 2 of 2

Thread: Sql problem - parameter mismatch count

  1. #1
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Symbian S60

    Talking Sql problem - parameter mismatch count

    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

  2. #2
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Sql problem - parameter mismatch count

    I don't know.May be there are 9 fields but you are binding 8 values.

Similar Threads

  1. Replies: 14
    Last Post: 16th May 2017, 04:51
  2. Parameter count mismatch in create table statement
    By croscato in forum Qt Programming
    Replies: 5
    Last Post: 4th February 2011, 10:38
  3. application parameter problem..
    By triperzonak in forum Newbie
    Replies: 7
    Last Post: 9th February 2009, 02:56
  4. Problem with connect() (enum-type as parameter)
    By alu23 in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 08:46
  5. Problem with unused parameter
    By devilj in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2007, 19:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.