I am using QT4.2.3 with PostgreSQL. I am having a following problem.
This is how my table looks like...
[first]
id (sequence) (int8)
fname
lname
When i did...
QSqlQuery query;
query.prepare("INSERT INTO first (fname, lname) VALUES (?, ?)");
query.addBindValue(QString(Fname));
query.addBindValue(QString(Lname))
query.exec();
I got a record inserted in my first table.
But is there any way to retrieve the id after inserting the data in the [first], as it is a sequence?
I have tried using a:
QVariant variant=query.lastInsertId();
int i=variant.toInt();
but I am always getting 0 as a result...
Doing something wrong?
When I try a driver feature It says It is OK.
Bookmarks