SQLite What am i doing wrong?
Code:
int row;
open conn...
qry.prepare("select rowid from my_table");
qry.exec();
while(qry.next()){
if(something==something2)
row=qry.value(0).toInt();
}
close conn...
open conn...
qry.prepare("UPDATE my_table"
"SET some=:some"
"WHERE rowid=:row");
qry.bindValue(":some", some);
qry.bindValue(":row",row);
if(qry.exec()){
...
close conn...
}
else{
QMessageBox::critical(this,tr
("error::"),qry.
lastError().
text());
close conn...
}
i rly don't understand what am i doing wrong...
note that my sql connections are working fine, ...
i keep getting error "no query unable to fetch row"
Thanks
Re: SQLite What am i doing wrong?
When reporting errors it is generally useful to specify where you get the error.
I guess line 13 or maybe 20. The qry object is associated withthe default database connection at the time the query was constructed. You close that connection at 'line' 10 so the qry object is no longer associated with a connection and you get the error when you try to use the connection.
Re: SQLite What am i doing wrong?
I am curious how you got the lines "open conn..." and "close conn..." to compile. If you're going to post code and ask us questions about it, at least post real code.
Here's a hint: How does the QSqlQuery you have created know what database to use when executing the query? Where have you told it anything about the database?