Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

SQL - get data into a QVariantList

I want to get data from my datatbase as a QVariantList using a select query.


So far I have:


QVariantList sqlData;
QSqlQuery sqlQuery(mDb);
sqlQuery.prepare("select * from users");
sqlData = sqlQuery.???
return sqlData;

 How can I get all rows from the database? I only seem to find get row not rows.



BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Posts: 17,024
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: SQL - get data into a QVariantList

if i don't need the key returned i use:


QVariant result = sqlDataAccess->execute("SELECT * FROM users");
QVariantList list = result.value<QVariantList>();

 (you can get the values of the variants using qDebug())


If i need the key i use:

QSqlQuery sqlQuery(queryString, sqlDataAccess->connection());
int key= sqlQuery.lastInsertId().toInt();


feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter