MYsql exec() query probleme
-
wrote on 17 Nov 2017, 08:43 last edited by
my qt project isn't adding anything to database , he can remove , display and edit all the date in my mysqlDatabase except adding without giving me any error ... and he can also add in onther tab in the same database
-
wrote on 20 Nov 2017, 09:39 last edited by
thanks guy for helping
the probleme was in mysql engine !!! you have to add innobd engine to your table in mysql -
my qt project isn't adding anything to database , he can remove , display and edit all the date in my mysqlDatabase except adding without giving me any error ... and he can also add in onther tab in the same database
-
wrote on 17 Nov 2017, 19:16 last edited by
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 ;
} -
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 afterarrive
that shouldn't be there. -
wrote on 18 Nov 2017, 11:48 last edited by
@JNBarchan
yes i've tried that also -
wrote on 18 Nov 2017, 11:52 last edited by JonB
@gdaboy
You certainly need to remove the extraneous'
than @SGaist noticed in his post above.I know from other SQLs that
INSERT
syntax 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 ? -
wrote on 20 Nov 2017, 09:39 last edited by
thanks guy for helping
the probleme was in mysql engine !!! you have to add innobd engine to your table in mysql
1/13