QSqlQuery bindValue problem



  • void CompanyInfo::on_zip_editingFinished()
    {
      QSqlQuery query;
      query.prepare("update company set zip=:zip");
      query.bindValue(":zip",ui->zip->text());
      query.exec();
    }
    
    void CompanyInfo::on_st_editingFinished()
    {
      QSqlQuery query;
      query.prepare("update company set st=:st");
      query.bindValue(":st",ui->st->text());
      query.exec();
        qDebug() << query.lastError();
    }
    

    In the above statements the zip works perfectly but the st gives me an "Parameters count mismatch". On the form both fields are line edits, even more the "st" is a copy of "zip", the columns in the database have exactly the same size and type (VARCHAR(10)). Completely lost...I tried putting "()" around the column name on the prepare statement and :st, but get the same error. I have another 6 similar statements on this sheet all work fine.



  • Solved my problem, i did not realized that when the database was created an extra " was added to the name of the column. When using SQLite there is no way to see exactly the name of the columns of a table. It shows you the creation command and because the extra " was on a line break i could not see it. Drove me crazy for a full day.


Log in to reply
 

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