我想从数据库中获取数据并在lineEdits上进行设置以生成用户个人资料
void Home::on_profilePB_clicked()
{
ui->stackedWidget->setCurrentIndex(5);
QSqlQuery query;
QString empID,firstname, lastname,empRole,CellNum,emailAddress,password,deptno,carRegistration;
query.exec("SELECT empID,firstname, lastname,empRole,CellNum,emailAddress,password,deptno,carRegistration FROM employee WHERE empID='"+ui->empIdEdit->text()+"'");
empID=query.value(0).toString();
firstname=query.value(1).toString();
lastname=query.value(2).toString();
empRole=query.value(3).toString();
CellNum=query.value(4).toString();
emailAddress=query.value(5).toString();
password=query.value(6).toString();
deptno=query.value(7).toString();
carRegistration=query.value(8).toString();
ui->empIDShow->setText(empID);
ui->lastNameEdit->setText(lastname);
ui->firstnameEdit->setText(firstname);
ui->contactNumEdit->setText(CellNum);
ui->jobRole->setText(empRole);
ui->emAdd->setText(emailAddress);
}
我收到此消息:
QSqlQuery :: value:不在有效记录上