Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlQuery bindValue problem
Qt 6.11 is out! See what's new in the release blog

QSqlQuery bindValue problem

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 939 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Dan3460D Offline
    Dan3460D Offline
    Dan3460
    wrote on last edited by Dan3460
    #1
    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.

    1 Reply Last reply
    0
    • Dan3460D Offline
      Dan3460D Offline
      Dan3460
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved