PDA

View Full Version : error from Qt version 2009.01 to 2009.02



cydside
9th June 2009, 22:26
Hi to all,
I've compiled the following and "same" code:



void frmCategorie_AME::inserisciCampi()
{
QString querySQL;
querySQL = QString("INSERT INTO %1 VALUES (NULL,:primo,:secondo,1,0)")
.arg(listaNomiPerTabella["nomeTabella"].toString());

QSqlQuery queryInserimento;
queryInserimento.prepare(querySQL);
queryInserimento.bindValue(":primo", ui.lnePrimo->text());
queryInserimento.bindValue(":secondo",
ui.cboSecondo->itemData(ui.cboSecondo->currentIndex()));
if (queryInserimento.exec())
{
qDebug() << "INSERT OK!";
qDebug() << queryInserimento.lastInsertId.toInt();
}
else
{
QMessageBox::critical(this, tr("Attenzione!"),
tr("Il database ha riportato un errore: %1")
.arg(queryInserimento.lastError().text()));
}
queryInserimento.finish();
}


unbeliveble but the latest version(2009.02) give me back the following error:



src\frmCategorie_AME.cpp: In member function `void frmCategorie_AME::inserisciCampi()':
src\frmCategorie_AME.cpp:15: error: insufficient contextual information to determine type
make[1]: *** [debug/frmCategorie_AME.o] Error 1


qDebug() << queryInserimento.lastInsertId.toInt(); == insufficient contextual information to determine type

HELP!!!
:crying:

wysota
9th June 2009, 22:38
You forgot the parenthesis after the "lastInsertId" statement. Try to find errors in yourself instead of blaming the compiler...

cydside
9th June 2009, 22:42
Did you try it???

Now, I'm really having that error with the same code!!! I'm not blaming the compiler, trust me!

wysota
9th June 2009, 22:54
I just know there is no public field "lastInsertId" in QSqlQuery but there is a public method with that name.

cydside
9th June 2009, 22:56
Anyway your suggestion is working on the latest version, thanks!

PS: If you have time, try it!