I have a form that has a combobox that gets populated from a database query. The combobox contains the first and last name of a person that I appended from the two fields in the table. I have used MS Access and you can hide columns in the combo box and retrieve them for search functions later. I can't figure out how to create the correct query. My thought process has gone several ways, but can't find the code to do it: I am thinking I might have to somehow pass the id to the slot?
Here is what I have so far:
void MainWindow::on_cmbRider_currentIndexChanged(int index)
{
Sqlstring="SELECT LName, FName , weight , notes * FROM rider WHERE id=" + ui->cmbRider->currentIndex(0); // this won't work because the id is not in the combobox.
query.prepare(Sqlstring);
query.exec();
ui->txtFName->text().clear();
ui->txtFName->text()=(query.value (0));//not sure if this will work either
}
void MainWindow::on_cmbRider_currentIndexChanged(int index)
{
QString Sqlstring;
QSqlQuery query ;
Sqlstring="SELECT LName, FName , weight , notes * FROM rider WHERE id=" + ui->cmbRider->currentIndex(0); // this won't work because the id is not in the combobox.
query.prepare(Sqlstring);
query.exec();
ui->txtFName->text().clear();
ui->txtFName->text()=(query.value (0));//not sure if this will work either
}
To copy to clipboard, switch view to plain text mode
Thanks for your help!
Bookmarks