How to handle auto_increment with bindvalue()



  • i have this simple table named Dependencies with following columns
    depe_ID : INT AUTO_INCREMENT PRIMARY KEY
    filename : varchar
    revision_number : INT

    i have this query to execute

     query.prepare("INSERT INTO Dependencies (depe_fileName,revision_number) "
                      "VALUES ( ? , ?)");
    
    
        
        query.bindValue(1,filename);
        query.bindValue(2, revision_number);
    

    i get this error :

    QSqlError("", "Parameter count mismatch", "")
    

  • Lifetime Qt Champion

    Hi,

    At first sight your position parameter to bindValue are wrong. You have two values so it should be 0 and 1 not 1 and 2.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.