Unsolved Too long to load data from Sql Server
-
This post is deleted! -
@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?
-
@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 -
This post is deleted! -
@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...
-
@jsulm i'm very sorry about that, please help me ! i was stucked for 2 days for its
-
@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?
-
@jsulm it's still dont make a difference .
-
Hi,
Which database plugin are you using ?
By the way, there's no need to allocate QSqlQuery on the heap. -
Hi, i'm using SQL Server
-
And how do you know that it's because of the query model?
What Qt version do you use? -
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 -
@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.
-
Sorry for my English. i'm using Qt5
-
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). -
okay, let me try it!
-
@Duy-Khang
Can we be clear whether it is specifically because you useQSqlQueryModel
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;
-
it's also takes about 10s to execute
-
@Duy-Khang
Which one takes 10 seconds? The 1-liner, the 4-liner, both? -
The 1-liner