PDA

View Full Version : Impossible to get data from QSqlQuery object[Solved]



jano_alex_es
27th April 2009, 14:33
Hi,

I have the next code:



QSqlQuery data(QString("SELECT sname, ssurname FROM games WHERE id =3")
,(the database, it works so the problem is not here));

QVariant QVtemp;
for(int i = 0; i < 2; ++i)
{
QVtemp = data.value(i);
QString test1= data.value(i).toString();
}



"test1" is always "". The query works fine, because data.size is 1, so I think the problem should be somewhere else... any idea?

thanks!

spirit
27th April 2009, 14:56
use QSqlQuery::next/previous/first/last/seek for navigation between records.

jano_alex_es
27th April 2009, 15:15
in the end my problem was that I didn't set up the record.

Something easy to find, thanks to you, with "data.First()" (and, after that, access with data.value(index))

thanks!