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. Ask for help (maybe) in query.value(0).
Forum Updated to NodeBB v4.3 + New Features

Ask for help (maybe) in query.value(0).

Scheduled Pinned Locked Moved Solved General and Desktop
qsqlquerymysqlselect
4 Posts 2 Posters 1.3k 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.
  • L Offline
    L Offline
    LuAria
    wrote on 28 Aug 2017, 11:44 last edited by
    #1

    Here is the code:

    QString s = QString("SELECT Numone, Numtwo FROM number");
    query.exec(s);

    while(query.next()){
    QString name1 = query.value(0).toString();

    QString name2 = query.value(1).toString(); <--it,'s wrong T^T
    qDebug()<<name1; / /Numone
    qDebug()<<name2; / /Numtwo
    }

    I want it to output the data of both Numone and Numtwo, however, it just showed me Numone.
    How can I get the data of both Numone and Numtwo?
    Thanks every viewer.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pradeep Kumar
      wrote on 28 Aug 2017, 12:02 last edited by
      #2

      Hi,

      did u check wat value ur getting from dB, and
      is value present in dB for Numtwo?.

      Thanks,

      Pradeep Kumar
      Qt,QML Developer

      L 1 Reply Last reply 28 Aug 2017, 12:11
      0
      • P Pradeep Kumar
        28 Aug 2017, 12:02

        Hi,

        did u check wat value ur getting from dB, and
        is value present in dB for Numtwo?.

        Thanks,

        L Offline
        L Offline
        LuAria
        wrote on 28 Aug 2017, 12:11 last edited by
        #3

        @Pradeep-Kumar Thanks for your respond!
        I have solved it after your suggestion.

        1 Reply Last reply
        1
        • P Offline
          P Offline
          Pradeep Kumar
          wrote on 29 Aug 2017, 03:54 last edited by
          #4

          hi,

          @LuAria ,

          wat ws the value coming in Numtwo ?.
          Nways ur got solution.
          Happy coding.

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

          1 Reply Last reply
          2

          2/4

          28 Aug 2017, 12:02

          • Login

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