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. SQL data extraction error
Forum Updated to NodeBB v4.3 + New Features

SQL data extraction error

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 180 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.
  • F Offline
    F Offline
    fkaraokur
    wrote on last edited by
    #1

    I have a query like this.

    query.prepare("Select * from Liste WHERE id=?");
    query.addBindValue(id_);
    query.exec();
    

    This query only returns 1 row of 4 columns. I checked this out.
    I want to get the column values in this single row. The following procedure did not work. What should I do?

    sql.png

    The following codes did not work. and it gives an error like this.

    qDebug()<<query.value(1).toString();
    
    

    QSqlQuery::value: not positioned on a valid record
    ""

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You have to call QSqlQuery::next() as explained in the documentation.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4

      • Login

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