PDA

View Full Version : dateEdit and timeEdit



aymenkn
28th March 2014, 12:09
Hey,
I have this function that inserted the data in the data base



void fenetre_admin::on_pushButton_ajoutE_clicked()
{
QString dn,hr;
dn=ui->dateEdit_DNE->date().toString("dd MM yyyy");
hr=ui->timeEdit_heureE->time().toString("h:m:s");
QSqlQuery qry;
qry.prepare("insert into Etudiant (DN,heur) values ('"+dn+"','"+hr+"')");
if(qry.exec()){
QMessageBox::critical(this,tr("Save"),tr("Save"));
conn.connClose();
}else{
QMessageBox::critical(this,tr("erreur::"),qry.lastError().text());
}}






{
QString mat;
mat=ui->lineEdit_rechmatE->text();
QSqlQuery qry;
qry.prepare("Select DN,heur from Etudiant where Matricu='"+mat+"');
if(qry.exec()){
while(qry.next()){
ui->dateEdit_DNE->setDate(qry.value0).toString());
ui->timeEdit_heureE->setTime(qry.value(1)toString());
}
}


type dn in the data base DATE
type hr in base data TIMESTAMP

the problem that the data does not appear in dateEdit and timeEdit