PDA

View Full Version : Sql select table query error



nagabathula
4th July 2011, 09:58
Hello friends i have a small problem in retrieving data from a sql database. I am able to save data into the table and even retrieve it in other parts of my program. But in this place i am having a sql error .



for(int i=0; i <dbrowcount.count();i++)
{
if((dbrowcount.at(i)>0)&&(dbrowcount.at(i)<33))
{
deletenum = dbrowcount.at(i);
QSqlQuery sqp("SELECT Box1 FROM tempBulkdb rowid ="+ QString::number(deletenum));
if(sqp.exec())
{
if (sqp.first())
{
do
{
boxtempchn.push_back(sqp.value(0).toString());
} while(sqp.next());
}
}

qDebug()<< sqp.lastError().text();
qDebug()<<boxtempchn;
}
dbrowcount has the row number and the size of the list. I have 10 nested else if condition i have put only the first condition , i am testing the first condition only now.
i get a sql error. I don't know if i am doing any thing wrong.
This is the Sql Error i am getting.

No query Unable to fetch row

thank you

stampede
4th July 2011, 11:03
I think you are missing WHERE in this following query:

QSqlQuery sqp("SELECT Box1 FROM tempBulkdb WHERE rowid ="+ QString::number(deletenum));

nagabathula
4th July 2011, 11:12
hello thank you so much. .. that was exactly the problem. I missed the WHERE clause. It works now.
Thank you