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. Too long to load data from Sql Server
Forum Updated to NodeBB v4.3 + New Features

Too long to load data from Sql Server

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 6 Posters 2.4k 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.
  • D Offline
    D Offline
    Duy Khang
    wrote on last edited by
    #1
    This post is deleted!
    jsulmJ 1 Reply Last reply
    0
    • D Duy Khang

      This post is deleted!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Duy-Khang Please provide more information:

      • Is the SQL server running on another machine?
      • How long does it take if you execute same query directly using command line SQL client?
      • How many rows do you have in that table?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 2 Replies Last reply
      0
      • jsulmJ jsulm

        @Duy-Khang Please provide more information:

        • Is the SQL server running on another machine?
        • How long does it take if you execute same query directly using command line SQL client?
        • How many rows do you have in that table?
        D Offline
        D Offline
        Duy Khang
        wrote on last edited by
        #3

        @jsulm SQL Server is on my machine
        it's has 11 rows and if i user command line SQL client then so fast to execute

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @Duy-Khang Please provide more information:

          • Is the SQL server running on another machine?
          • How long does it take if you execute same query directly using command line SQL client?
          • How many rows do you have in that table?
          D Offline
          D Offline
          Duy Khang
          wrote on last edited by Duy Khang
          #4
          This post is deleted!
          jsulmJ 1 Reply Last reply
          0
          • D Duy Khang

            This post is deleted!

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Duy-Khang said in Too long to load data from Sql Server:

            do u have facebook account ?
            i'll send you video to watch.

            I consider such posts to be spam...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            D 1 Reply Last reply
            0
            • jsulmJ jsulm

              @Duy-Khang said in Too long to load data from Sql Server:

              do u have facebook account ?
              i'll send you video to watch.

              I consider such posts to be spam...

              D Offline
              D Offline
              Duy Khang
              wrote on last edited by
              #6

              @jsulm i'm very sorry about that, please help me ! i was stucked for 2 days for its

              jsulmJ 1 Reply Last reply
              0
              • D Duy Khang

                @jsulm i'm very sorry about that, please help me ! i was stucked for 2 days for its

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Duy-Khang said in Too long to load data from Sql Server:

                i'm very sorry about that

                OK, no problem.

                Try to do it like shown here: https://doc.qt.io/qt-5/qsqlquerymodel.html (without QSqlQuery)

                modal = new QSqlQueryModel();
                modal->setQuery("SELECT name, salary FROM employee");
                ui->tableView->setModel(modal);
                

                Does it make a difference?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                D 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @Duy-Khang said in Too long to load data from Sql Server:

                  i'm very sorry about that

                  OK, no problem.

                  Try to do it like shown here: https://doc.qt.io/qt-5/qsqlquerymodel.html (without QSqlQuery)

                  modal = new QSqlQueryModel();
                  modal->setQuery("SELECT name, salary FROM employee");
                  ui->tableView->setModel(modal);
                  

                  Does it make a difference?

                  D Offline
                  D Offline
                  Duy Khang
                  wrote on last edited by
                  #8

                  @jsulm it's still dont make a difference .

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

                    Hi,

                    Which database plugin are you using ?
                    By the way, there's no need to allocate QSqlQuery on the heap.

                    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
                    • D Offline
                      D Offline
                      Duy Khang
                      wrote on last edited by
                      #10

                      Hi, i'm using SQL Server

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        And how do you know that it's because of the query model?
                        What Qt version do you use?

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          Duy Khang
                          wrote on last edited by
                          #12

                          because if i don't use the query model then when click to Xem push button, it's work
                          and if i use the query model. it takes about 30s to load data from SQL Server.
                          Version is Qt Creator 4.14.0

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @Duy-Khang said in Too long to load data from Sql Server:

                            click to Xem push button, it's work

                            ?

                            Version is Qt Creator 4.14.0

                            we don't care which IDE (and it's version) you use - we want to use what Qt version you're using for developing.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            Pl45m4P 1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              Duy Khang
                              wrote on last edited by
                              #14

                              Sorry for my English. i'm using Qt5

                              JonBJ 1 Reply Last reply
                              0
                              • Christian EhrlicherC Christian Ehrlicher

                                @Duy-Khang said in Too long to load data from Sql Server:

                                click to Xem push button, it's work

                                ?

                                Version is Qt Creator 4.14.0

                                we don't care which IDE (and it's version) you use - we want to use what Qt version you're using for developing.

                                Pl45m4P Offline
                                Pl45m4P Offline
                                Pl45m4
                                wrote on last edited by Pl45m4
                                #15

                                @Christian-Ehrlicher

                                I assume @Duy-Khang is using 5.15.2 MinGW (the debug output, you can see in the screenshot). So it's probably not some weird buggy behavior

                                @Duy-Khang have you tried any other query or any other database? Can you print the query result to console?
                                Set breakpoints to see where it crashes (during the query execution or while filling your tableView/model with data).


                                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                ~E. W. Dijkstra

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  Duy Khang
                                  wrote on last edited by
                                  #16

                                  okay, let me try it!

                                  1 Reply Last reply
                                  0
                                  • D Duy Khang

                                    Sorry for my English. i'm using Qt5

                                    JonBJ Online
                                    JonBJ Online
                                    JonB
                                    wrote on last edited by JonB
                                    #17

                                    @Duy-Khang
                                    Can we be clear whether it is specifically because you use QSqlQueryModel that you are seeing slow behaviour?

                                    What is the timing if you just use:

                                    query = new QSqlQuery("SELECT * FROM Lecturer_DATABASE");
                                    

                                    ?
                                    And what about:

                                    int count = 0;
                                    query = new QSqlQuery("SELECT * FROM Lecturer_DATABASE");
                                    while (query.next()) 
                                        qDebug() << ++count;
                                    
                                    1 Reply Last reply
                                    0
                                    • D Offline
                                      D Offline
                                      Duy Khang
                                      wrote on last edited by
                                      #18

                                      it's also takes about 10s to execute

                                      JonBJ 1 Reply Last reply
                                      0
                                      • D Duy Khang

                                        it's also takes about 10s to execute

                                        JonBJ Online
                                        JonBJ Online
                                        JonB
                                        wrote on last edited by
                                        #19

                                        @Duy-Khang
                                        Which one takes 10 seconds? The 1-liner, the 4-liner, both?

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          Duy Khang
                                          wrote on last edited by
                                          #20

                                          The 1-liner

                                          JonBJ 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