Solved Question in QSqlQuery
-
Hello Word
Im New in Qt
I have problem in m'y app
This is m'y codevoidDialog::on_tableView_activated(constQModelIndex&index)
{
QString valu=ui->tableView->model()->data(index).toString();QSqlQuery qryview;
qryview.prepare("SELECT* FROM employ where nomper='"+valu+"' or prenomper='"+valu+"'")
ui->lineEdit_2->setText(qryview.value(0).toString()); ui->lineEdit_3->setText(qryview.value(1).toString());}
I want to recuperer m'y data in Qlineedit
When i use sqlite no probleme
But When i use mysql no resultat in linEdit -
Hi and welcome to the forums.
Did you install mysql client libraries as well from their site?
With Sqlite all is included but with MySql you have to supply the client libs your self. Maybe even build plugin. -
@mrjj
Yes i m install mysql client
This is message debug
qsqlquery::value: not positioned on a valid record -
@Binary said in Question in QSqlQuery:
not positioned on a valid record
Thats normally something with the syntax or no row was matched.
Check what error() returns and try a plain "Select *" with no where part.
also might just be a missing ' -
@mrjj
this is queryDebugqsqlquery::value: not positioned on a valid record.
-
@Binary
Hi
You grab the value directly
qryview.value(1).toString());normally one will use first() or next() to place on valid record.
please consult the docs. its explained in detail there.
Normal sample is likeQSqlQuery query("SELECT country FROM artist"); while (query.next()) { QString country = query.value(0).toString(); }
-
@mrjj said in Question in QSqlQuery:
@Binary
Hi
You grab the value directly
qryview.value(1).toString());normally one will use first() or next() to place on valid record.
please consult the docs. its explained in detail there.
Normal sample is likeQSqlQuery query("SELECT country FROM artist"); while (query.next()) { QString country = query.value(0).toString(); }
thank you