Erreur de Validation SQL par un calcul.
Bonjour, je travaille actuellement sur un petit projet de facture en C # Et je rencontre un problème lorsque je veux utiliser un calcul a partir des champs de la base de données.
Le Insert Into de la base SQL est alors refusée.
Et que vous pourriez m'aider si vous plait, Merci D'avance :)
Voici donc une parti du code.
La partie insertion.
Code:
1 2 3 4 5 6 7 8 9 10 11
| String d=dateTimePicker1.Value.Year.ToString()+"-"+dateTimePicker1.Value.Month.ToString()+"-"+dateTimePicker1.Value.Day.ToString();
MySqlCommand cmdInsert=MainForm.obj.CreateCommand();
cmdInsert.CommandText="insert into facture(nbs_semaines,date) values ("+textBox9.Text+",'"+d+"')";
cmdInsert.ExecuteNonQuery();
MySqlCommand cmdcInsert=MainForm.obj.CreateCommand();
cmdcInsert.CommandText="insert into client(nom,prenom,adresse,cp,ville,telephone,courriel) values ('"+textBox1.Text+"','"+textBox2.Text+"','"+textBox3.Text+"',"+textBox4.Text+",'"+textBox5.Text+"',"+textBox6.Text+",'"+textBox7.Text+"')";
cmdcInsert.ExecuteNonQuery();
Facture objFA= new Facture();
objFA.ShowDialog(); |
Et la partie qui affiche la facture et utilise les formules de calcul.
Code:
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
| MySqlCommand cmdSelect2=MainForm.obj.CreateCommand();
cmdSelect2.CommandText="select * from facture";
MySqlDataReader resultat0=cmdSelect2.ExecuteReader();
while (resultat0.Read())
{
label9.Text=resultat0.GetValue(0).ToString();
label17.Text=resultat0.GetValue(2).ToString();
label6.Text=resultat0.GetValue(1).ToString();
}
resultat0.Close();
MySqlCommand cmdSelect3=MainForm.obj.CreateCommand();
cmdSelect3.CommandText="select * from destination";
MySqlDataReader resultat1=cmdSelect3.ExecuteReader();
while (resultat1.Read())
{
label15.Text=resultat1.GetValue(1).ToString();
}
resultat1.Close();
int semaines=int.Parse(resultat0.GetValue(1).ToString());
double prix=double.Parse(resultat1.GetValue(2).ToString());
double HT=(prix*semaines);
double TTC=(HT*1.196);
label18.Text=HT.ToString();
label18.Text=TTC.ToString(); |