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. Question in QSqlQuery
Forum Updated to NodeBB v4.3 + New Features

Question in QSqlQuery

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 825 Views 2 Watching
  • 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.
  • B Offline
    B Offline
    Binary
    wrote on last edited by
    #1

    Hello Word
    Im New in Qt
    I have problem in m'y app
    This is m'y code

    voidDialog::on_tableView_activated(constQModelIndex&index)

    {

    QString valu=ui->tableView->model()->data(index).toString();QSqlQuery qryview;

    qryview.prepare("SELECT* FROM employ where nomper='"+valu+"' or prenomper='"+valu+"'")

    ui->lineEdit_2->setText(qryview.value(0).toString()); ui->lineEdit_3->setText(qryview.value(1).toString());}

    I want to recuperer m'y data in Qlineedit

    When i use sqlite no probleme
    But When i use mysql no resultat in linEdit

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to the forums.
      Did you install mysql client libraries as well from their site?
      With Sqlite all is included but with MySql you have to supply the client libs your self. Maybe even build plugin.

      B 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi and welcome to the forums.
        Did you install mysql client libraries as well from their site?
        With Sqlite all is included but with MySql you have to supply the client libs your self. Maybe even build plugin.

        B Offline
        B Offline
        Binary
        wrote on last edited by
        #3

        @mrjj
        Yes i m install mysql client
        This is message debug
        qsqlquery::value: not positioned on a valid record

        mrjjM 1 Reply Last reply
        0
        • B Binary

          @mrjj
          Yes i m install mysql client
          This is message debug
          qsqlquery::value: not positioned on a valid record

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Binary said in Question in QSqlQuery:

          not positioned on a valid record

          Thats normally something with the syntax or no row was matched.
          Check what error() returns and try a plain "Select *" with no where part.
          also might just be a missing '

          B 1 Reply Last reply
          0
          • mrjjM mrjj

            @Binary said in Question in QSqlQuery:

            not positioned on a valid record

            Thats normally something with the syntax or no row was matched.
            Check what error() returns and try a plain "Select *" with no where part.
            also might just be a missing '

            B Offline
            B Offline
            Binary
            wrote on last edited by
            #5

            @mrjj
            this is queryDebug

            qsqlquery::value: not positioned on a valid record.

            mrjjM 1 Reply Last reply
            0
            • B Binary

              @mrjj
              this is queryDebug

              qsqlquery::value: not positioned on a valid record.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @Binary
              Hi
              You grab the value directly
              qryview.value(1).toString());

              normally one will use first() or next() to place on valid record.
              please consult the docs. its explained in detail there.
              Normal sample is like

                QSqlQuery query("SELECT country FROM artist");
                  while (query.next()) {
                      QString country = query.value(0).toString();
                    
                  }
              
              B 1 Reply Last reply
              2
              • mrjjM mrjj

                @Binary
                Hi
                You grab the value directly
                qryview.value(1).toString());

                normally one will use first() or next() to place on valid record.
                please consult the docs. its explained in detail there.
                Normal sample is like

                  QSqlQuery query("SELECT country FROM artist");
                    while (query.next()) {
                        QString country = query.value(0).toString();
                      
                    }
                
                B Offline
                B Offline
                Binary
                wrote on last edited by
                #7

                @mrjj said in Question in QSqlQuery:

                @Binary
                Hi
                You grab the value directly
                qryview.value(1).toString());

                normally one will use first() or next() to place on valid record.
                please consult the docs. its explained in detail there.
                Normal sample is like

                  QSqlQuery query("SELECT country FROM artist");
                    while (query.next()) {
                        QString country = query.value(0).toString();
                      
                    }
                

                thank you

                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