c++ - Getting a record from SQLite? -


how can specified record table , row? example:

here pseudo structure of datebase (sqlite):

row1 row2 row3 line1 line1 line1 line2 line2 line2 ... ... ... 

i want use line record datebase via qt. example how can row2->line2 string?

i tried this:

qsqldatabase db = qsqldatabase::adddatabase("qsqlite");  db.setdatabasename("db.db"); //yes name of datebase db.db    if (db.open()) {     qsqlquery sorual("select question questions",db);     sorual.exec();sorual.first(); //these line not affect result "qsqlquery::value: not positioned on valid record".      qdebug() << sorual.value(5).tostring(); // here want 5. line of question row in questions table. } else {     qdebug() << "error"; } 

but response debugger "qsqlquery::value: not positioned on valid record"

you're doing wrong. here's the example of doing right

also recommend read qtsqlquery help - described there. great 1 of strongest advantages of using qt.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -