PDA

View Full Version : How to find result of a query in qsqlite?



newtowindows
28th October 2009, 12:32
Hi...previously i am gtk programmer(new to qt),

qsqlquery.exec() function takes only one parameter which is query string. we are not passing any additional parameters to catch the results(like string * or ..etc).So how can i catch the result returned by sqlite database after running a qsqlquery.exec(). I have seen examples but they shown only how to enter the details in db. not shown how to catch the results(ex: table values, names ...etc) returned by db. please any one give me sample code lines for reading tables in sqlite database in qt 4.5.X? I think i have to use qsqlresult class. But i don't know how to use that class because i didnt found any examples which shows a proper code.

spirit
28th October 2009, 12:40
there is an example in Qt Assistant how to use QSqlQuery


QSqlQuery query("SELECT country FROM artist");
while (query.next()) {
QString country = query.value(0).toString();
doSomething(country);
}