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

Scott Aron Bloom Scott.Bloom at onshorecs.com
Mon Jul 5 19:50:46 CEST 2010


I don't understand why it matters.  

You could do this...

If you need to be back at the beginning of the query, just do a
query.seek( -1 )...

bool ok = query.exec();
while( aOK && query.next() )
{}
query.seek( -1 );


I think it will probably depend upon the SQL driver and SQL Server
backend if all the data is transferred on the .exec


Scott
-----Original Message-----
From: Roland Tollenaar [mailto:rwatollenaar at gmail.com] 
Sent: Monday, July 05, 2010 10:45 AM
To: Scott Aron Bloom
Cc: Qt-Interest
Subject: Re: [Qt-interest] qsqlquery: method query.next() makes call to
database!!!

Hi,

thanks for this.

Is there any way to ensure all the data is transferred on the exec call
and NOT bit by bit (excuse the pun) in the while loop?

Regards

Roland

Scott Bloom wrote:
> 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
> 
> _______________________________________________
> 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