1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| void ajouteProduit(QSqlDatabase bd)
{
string ref_fam, ref;
QString Qref_fam, Qref;
afficheFamille(bd);
cout << "\n Entrez la référence de la famille : " << endl;
cin >> ref_fam;
Qref_fam.fromStdString(ref_fam);
cout << "\n Entrez la référence du produit : " << endl;
cin >> ref;
Qref.fromStdString(ref);
QSqlQuery req_prep;
if (req_prep.prepare("INSERT INTO Produit VALUES(?,?)"))
{
QVariantList ref, ref_fam;
ref_fam << Qref_fam ;
req_prep.addBindValue(ref_fam);
ref << Qref;
req_prep.addBindValue(ref);
if (req_prep.execBatch())
{
cout << "\nok\n" << endl;
int plop2;
cin >> plop2;
}
else
{
cout << "\nCa ne marche pas : " << q2c(bd.lastError().text()) << endl;
int plop2;
cin >> plop2;
}
afficheProduit(bd);
}
else
{
cout << "\nEchec de la requête d'insertion dans la fonction ajouteProduit(), endroit : main.cpp.\n Erreur : " << q2c(bd.lastError().text()) << endl;
int plop2;
cin >> plop2;
}
} |
Partager