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::value: not positioned on a valid record
QtWS25 Last Chance

QSqlQuery::value: not positioned on a valid record

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.8k 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.
  • R Offline
    R Offline
    redstoneleo
    wrote on last edited by
    #1

    After setting up a table model like this:
    code is "here":http://stackoverflow.com/questions/20813955/qsqlqueryvalue-not-positioned-on-a-valid-record

    the content is displayed properly, but when I edit the data item then press enter ,this error occurred (more accurately, it is a warning rather than an error ,because the application doesn't crash when it happened .):
    @
    QSqlQuery::value: not positioned on a valid record
    @

    when I close the application and restart it again ,I found the editing I did last time is not stored into the database ,anyone can fix my problem here .

    Note:I did not use
    @
    model->removeColumn(0)
    @

    here.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Seba84
      wrote on last edited by
      #2

      You already have been answered on the stackoverflow.com thread.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        redstoneleo
        wrote on last edited by
        #3

        yes ,but that perhaps is not the right answer .
        [quote author="Seba" date="1388252761"]You already have been answered on the stackoverflow.com thread.[/quote]

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Laszlo's answers are good

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            redstoneleo
            wrote on last edited by
            #5

            when I move model.setTable("names" ) and model.select() after the model.setRelation(0, QSqlRelation( "salaries", "id", "annual" ) ), just like this
            http://codepad.org/zqri28oj ,
            the problem disappeared . I don't understand why ,can you explain it ?
            [quote author="SGaist" date="1388351689"]Laszlo's answers are good[/quote]

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              If I'm not mistaken, you need only to move select after setRelation.

              The call to select populates the model data, if you set the relation after, you're too late retrieve the data concerning the relation.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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