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 different value() type
QtWS25 Last Chance

QSqlQuery different value() type

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsqlquerymysqlqvariant5.6.0
13 Posts 2 Posters 4.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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 30 Mar 2016, 21:12 last edited by
    #2

    Hi,

    What database driver are you using ?

    Can you share the code you use to connect to the database ?

    What version were you using before 5.6 ?

    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
    • X Offline
      X Offline
      Xardas
      wrote on 31 Mar 2016, 08:42 last edited by Xardas
      #3

      Hi, previous version 5.5.1

      main connection:

      db = new QSqlDatabase();
      *db = QSqlDatabase::addDatabase("QMYSQL");
      db->setHostName("127.0.0.1");
      db->setPort(3306);
      db->setDatabaseName("testDB");
      db->setUserName("root");
      db->setPassword("1234567890");
      
      if (db->open())
         doSomething();
      else
         qDebug() << db->lastError();
      

      inside taskThread:

      void TaskThread::run()
      {
         db = new QSqlDatabase();
         *db = QSqlDatabase::cloneDatabase(QSqlDatabase::database(),
          QString::number((qintptr)QThread::currentThread()));
      
         if (db->open())
            emit result(doSomething());
         else
            return;
      }
      
      QString TaskThread::doSomething()
      {
         QSqlQuery query(*db);
         query.prepare("SELECT test.test1.id FROM test.test1"
         " WHERE test.test1.name=:name;");
         query.bindValue(":name", "name");
      
         if(query.exec() && query.first())
             return query.value(0).toString();
         else
             return 0;
      }
      

      driver - QMYSQL plugin from source
      MySql server version 5.7.11

      1 Reply Last reply
      0
      • X Offline
        X Offline
        Xardas
        wrote on 31 Mar 2016, 13:36 last edited by
        #4

        Checked again, on 5_5_1 has no problem.
        first table: QVariant(uint, 1);
        second table: QVariant(uint, 1);

        any ideas, what is the problem?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 31 Mar 2016, 18:51 last edited by
          #5

          One unrelated note, you're not using QSqlDatabase correctly. There's no need to use new on it.

          What OS and MySQL version are you using ?

          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
          1
          • X Offline
            X Offline
            Xardas
            wrote on 1 Apr 2016, 08:09 last edited by
            #6

            OS: Windows 10
            Mysql: 5.7.11

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 1 Apr 2016, 20:21 last edited by
              #7

              Did you only change Qt version or also MySQL ?

              Did you rebuild the MySQL plugin ?

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

              X 1 Reply Last reply 2 Apr 2016, 08:42
              0
              • S SGaist
                1 Apr 2016, 20:21

                Did you only change Qt version or also MySQL ?

                Did you rebuild the MySQL plugin ?

                X Offline
                X Offline
                Xardas
                wrote on 2 Apr 2016, 08:42 last edited by
                #8

                @SGaist said:

                Did you only change Qt version or also MySQL ?

                only Qt version

                @SGaist said:

                Did you rebuild the MySQL plugin ?

                Yes

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 2 Apr 2016, 21:38 last edited by
                  #9

                  What size are both tables ?

                  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
                  • X Offline
                    X Offline
                    Xardas
                    wrote on 3 Apr 2016, 08:55 last edited by
                    #10

                    first: 16KiB
                    second: 16KiB

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 3 Apr 2016, 14:04 last edited by
                      #11

                      I meant number of rows of each tables.

                      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
                      • X Offline
                        X Offline
                        Xardas
                        wrote on 3 Apr 2016, 14:10 last edited by
                        #12

                        first table 129
                        second 3

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 3 Apr 2016, 17:36 last edited by
                          #13

                          The plugin hasn't changed anything related to that between 5.5 and 5.6 so I wonder if it's a change in QVariant.

                          By the way, why do you need that information ? You should be able to just convert to int without any problem.

                          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

                          11/13

                          3 Apr 2016, 14:04

                          • Login

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