Bonjour,
J'ai crée un programme de gestion, dans ce programme j'ai deux boutons ajouter et modifier, mais le probleme c'est que mes boutons fonctionnent pas il me marque une erreur sur les deux boutons lorsque je fais Executer(F9).
Erreur de syntaxe dans l'instruction UPDATE. (pour le bouton modifier).
Erreur de syntaxe dans l'instruction INSERT INTO. (pour le bouton Ajouter)
Ce que je comprends pas c'est que j'ai ecris presque le même code avec une autre Form ouil y avait un bouton Ajouter et modifier j'ai recopié exactement la même syntaxe mais en vain il y a toujours une erreur.
Voici le code en question où il y a erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 procedure TPersonnel.BitBtn1Click(Sender: TObject); begin if (edit1.text='') or (edit2.text='') or (edit3.text='') or (edit4.text='') or (edit6.text='') or (edit7.text='') or (edit8.text='') or (edit9.text='') or (edit10.text='') then begin messagedlg('Tous les champs ne sont pas remplis',mtWarning,[mbok],0); end else with DataModule5.ADOQ_Personnel do begin SQL.Clear; SQL.Add('INSERT INTO PERSONNEL'); SQL.Add('(JUSTIFICATION,NOM,PRENOM,ADRESSE,CODE_POSTAL,LOCALITE,DATE,MATRICULE,TELEPHONE)'); SQL.Add(format('values(''%s'',''%s'',''%s'',''%s'',''%s'',''%s'',''%s'',''%s'',''%s'')', [edit1.Text,edit2.text,edit3.Text,edit4.text,edit6.text,edit7.text,edit8.text,edit9.text,edit10.text])); ExecSQL; begin with DataModule5.ADOQ_Fonction do begin SQL.Clear; SQL.Add('SELECT * FROM Personnel ORDER BY NOM'); Open; edit1.text:=''; edit2.text:=''; edit3.text:=''; edit4.text:=''; edit5.text:=''; edit6.text:=''; edit7.text:=''; edit8.text:=''; edit9.text:=''; edit10.text:=''; end; messagedlg('Ajout réussi',mtWarning,[mbok],0); Personnel.Visible:=false; Importation_Personnel.visible:=true; end; end; end;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 procedure TPersonnel.BitBtn2Click(Sender: TObject); begin with DataModule5.ADOQ_Personnel do begin SQL.Clear; SQL.Add('UPDATE PERSONNEL set JUSTIFICATION=:Justification, NOM=:Nom, PRENOM=:Prenom, ADRESSE=:Adresse, CODE_POSTAL=:Code_Postal, LOCALITE=:Localite, DATE=:Date, MATRICULE=:Matricule, TELEPHONE=:Telephone'); SQL.Add('WHERE JUSTIFIC1ATION=:OldType and NOM=:OldType1 and PRENOM=:OldType2 and ADRESSE=:OldType3 and CODE_POSTAL=:OldType4 and LOCALITE=:OldType5 and DATE=:OldType6 and MATRICULE=:OldType7 and TELEPHONE=:OldType8'); Parameters.ParamByName('Justification').Value:=edit1.Text; Parameters.ParamByName('OldType').Value:=OldType; Parameters.ParamByName('Nom').Value:=edit2.Text; Parameters.ParamByName('OldType1').Value:=OldType1; Parameters.ParamByName('Prenom').Value:=edit3.Text; Parameters.ParamByName('OldType2').Value:=OldType2; Parameters.ParamByName('Adresse').Value:=edit4.Text; Parameters.ParamByName('OldType3').Value:=OldType3; Parameters.ParamByName('Code_Postal').Value:=edit6.Text; Parameters.ParamByName('OldType4').Value:=OldType4; Parameters.ParamByName('Localite').Value:=edit7.Text; Parameters.ParamByName('OldType5').Value:=OldType5; Parameters.ParamByName('Date').Value:=edit8.Text; Parameters.ParamByName('OldType6').Value:=OldType6; Parameters.ParamByName('Matricule').Value:=edit9.Text; Parameters.ParamByName('OldType7').Value:=OldType7; Parameters.ParamByName('Telephone').Value:=edit10.Text; Parameters.ParamByName('OldType8').Value:=OldType8; ExecSQL; end; end;
Merci d'avance pour votre aide.
Partager