MYsql exec() query probleme
-
i am sorry ```
//QSqlQuery qry ;
qry.prepare("INSERT INTO flight arrive VALUES(:arrive')");
qry.bindValue(":arrive","98");
if(qry.exec()) {
qDebug()<<"fine";
return true ;
}
else{
qDebug()<<qry.lastError().text() ;
return false ;
}@gdaboy
Hi
is table name really "flight arrive" ?
If it really have a space, i think you need to quote it. please check mysql docs.
Also syntax looks a bit odd ?QSqlQuery query; query.prepare("INSERT INTO employee (id, name, salary) " "VALUES (:id, :name, :salary)"); query.bindValue(":id", 1001); ... -
i am sorry ```
//QSqlQuery qry ;
qry.prepare("INSERT INTO flight arrive VALUES(:arrive')");
qry.bindValue(":arrive","98");
if(qry.exec()) {
qDebug()<<"fine";
return true ;
}
else{
qDebug()<<qry.lastError().text() ;
return false ;
} -
@gdaboy
Hi
is table name really "flight arrive" ?
If it really have a space, i think you need to quote it. please check mysql docs.
Also syntax looks a bit odd ?QSqlQuery query; query.prepare("INSERT INTO employee (id, name, salary) " "VALUES (:id, :name, :salary)"); query.bindValue(":id", 1001); ... -
@mrjj
no tbale name is only flight and all i want to do is add a something in arrive coloum -
Hi,
Unless it's a typo here you have a
'right afterarrivethat shouldn't be there. -
@gdaboy
You certainly need to remove the extraneous'than @SGaist noticed in his post above.I know from other SQLs that
INSERTsyntax isINSERT INTO <table> (<column1>, <column2>, ...) VALUES (<value1>, <value2>, ...), i.e. columns must be inside()as well as values. I don't know whether MySQL accepts the column list without(), so you may or may not need that also. Personally, I think it's clearer anyway to parenthesize them. -
You should also post the error message returned for your query.
Also, what version of Qt are you using ?