How can I get a specified record from a table and row? Example:
Here is a pseudo structure of the datebase (sqlite):
Row1 Row2 Row3
Line1 Line1 Line1
Line2 Line2 Line2
... ... ...
I want to use get a line record from the datebase via Qt. For example how can I get Row2->Line2 string?
I tried this:
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("db.db"); //Yes the name of datebase is db.db
if (db.open())
{
QSqlQuery soruAl("SELECT question FROM questions",db);
soruAl.exec();soruAl.first(); //These line does not affect result "QSqlQuery::value: not positioned on a valid record".
qDebug() << soruAl.value(5).toString(); // Here I want to get the 5. line of the question row which is in questions table.
}
else
{
qDebug() << "Error";
}
But only response I get from debugger is "QSqlQuery::value: not positioned on a valid record"