PDA

View Full Version : problem with SELECT NEXTVAL



pippo42
8th March 2010, 09:30
Hello!

I would need to carry out a SELECT NEXTVAL but its does not work. Here is the code.



query.exec("SELECT NEXTVAL(\'mytable\');")
query.next();
cout << query.value(0).toInt() << "\n";


I obtain an error message saying that I am not on a valid record. Indeed, query.next() and query.exec("...") return false but with a lastError().text() empty. The function query.isSelect() also returns false.

What can I do?

Thanks!

waynew
8th March 2010, 21:43
What database type are you using?

I would use query.last() (not query.next())
That positions you on the query you just executed.

pippo42
22nd March 2010, 14:24
Thanks!
Sorry for the delay. I had waited a little for a reply and then I assumed I would not get any.

Best regards

Lesiok
23rd March 2010, 06:35
After execute query look with QSqlDatabase::lastError() and QSqlQuery::lastError() what happen.