Welcome!

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

Reply
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook

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");
sqlQuery.exec();
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
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

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());
sqlQuery.exec();
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