[Qt-interest] qsqlquery: method query.next() makes call to database!!!

Scott Bloom scott.bloom at onshorecs.com
Mon Jul 5 18:50:37 CEST 2010


Ive had this exact problem..  For the most part, using the get as needed is
a better solution (allows for your app to respond and start showing partial
results)

You can do the .exec and the while loop and then use the data..

Just make sure the event loop isnt used...


On 7/5/10 4:50 AM, "Roland Tollenaar" <rwatollenaar at gmail.com> wrote:

> Hi,
> 
> I have discovered something rather surprising and that is that in code
> of the following flow:
> 
> %%%%%%%%%%%%%%%%%%%%%%%%
> 
> QSqlquery query;
> QStringList StoreList;
> 
> bool ok=query.exec("SELECT * from LargeTable");
> 
> 
> 
> if(ok){
> 
> QMessageBox::information("data retrieved succesfully!");
> 
> while(query.next()){
> StoreList<<query.value(0).toString();
> }
> 
> 
> }
> 
> %%%%%%%%%%%%%%%%%%%%%%%
> 
> that during the period that the program is working in the while loop, it
> is not possible to disconnect the PC from the network if the database is
> not on the local machine.
> 
> In other words, the next() call or the value() call accesses the
> database server.!
> 
> In our specific case this is a problem.
> 
> The question is: Is it possible to set the behavior of QSQlquery to load
> all records onto the local machine before processing?
> 
> TIA,
> 
> Regards,
> 
> Roland
> 
> 
> 
> 
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list