Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QSqlQuery::value: not positioned on a valid record

    General and Desktop
    3
    6
    2512
    Loading More Posts
    • 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
      redstoneleo last edited by

      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 Reply Quote 0
      • S
        Seba84 last edited by

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

        1 Reply Last reply Reply Quote 0
        • R
          redstoneleo last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • R
              redstoneleo last edited by

              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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • First post
                  Last post