I don't understand what you mean with assign en contents.
Can you give me a little example?.
Thank in advance.
I don't understand what you mean with assign en contents.
Can you give me a little example?.
Thank in advance.
Here you assign to the variable called name:
Qt Code:
name = (query.value(0).toString());To copy to clipboard, switch view to plain text mode
If you want to make a search you need something like this:
Do you see the difference?Qt Code:
while ( query.next() ) if(name == query.value(0).toString()){ leFirst->setText( name ); break; } }To copy to clipboard, switch view to plain text mode
Yes i see the differents.
It works fine.
Thak you for your time and answer.
Of course it would be simpler to do it this way:
Qt Code:
void MainWindow::search() { searchDialog dlg(this); QSqlQuery query; query.prepare("SELECT firstname FROM person WHERE firstname==:name"); query.bindValue(":name", dlg.nameComboBox->currentText()); if(query.exec() && query.hasNext()) leFirst->setText( name); } }To copy to clipboard, switch view to plain text mode
Bookmarks