Salut à tous,

j'ai un souci lorsque je veux mettre à jour un enregistrement dans une table mysql, voici mon code:
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
 
  ADOQuery1.Close;
  ADOQuery1.SQL.Clear;
  ADOQuery1.SQL.Add('SELECT AP_ID_Lecteur, AP_Type_support, EXTRACT(YEAR FROM AP_Date_Pret) AS annee, COUNT( * )');
  ADOQuery1.SQL.Add('FROM archives_prets');
  ADOQuery1.SQL.Add('GROUP BY annee,AP_ID_Lecteur,AP_Type_support');
  ADOQuery1.SQL.Add('ORDER BY annee,AP_ID_Lecteur,AP_Type_support');
  ADOQuery1.Active;
  ADOQuery1.Open;
  ProgressBar1.Visible := True;
  ProgressBar1.Position := 0;
  ProgressBar1.Max := ADOQuery1.RecordCount;
  ADOQuery1.first;
  while not ADOQuery1.Eof do
  begin
    xidlect := ADOQuery1.Fields[0].AsInteger;
    xsupport := ADOQuery1.Fields[1].AsString;
    xannee := ADOQuery1.Fields[2].AsInteger;
    xcount := ADOQuery1.Fields[3].AsInteger;
    if pret_annee.Locate('Id_Lect;Annee', VarArrayOf([xidlect, xannee]), [loCaseInsensitive]) then
      pret_annee.Edit
    else pret_annee.Append;
 
    pret_annee.Fields[8].AsInteger := xidlect; //id_lect
    pret_annee.Fields[1].AsInteger := xannee; //annee
    if xsupport = '1' then
      pret_annee.Fields[2].AsInteger := xcount; //pret_mono
    if xsupport = '2' then
      pret_annee.Fields[3].AsInteger := xcount; //pret_perio
    if xsupport = '3' then
      pret_annee.Fields[4].AsInteger := xcount; //pret_son
    if xsupport = '4' then
      pret_annee.Fields[5].AsInteger := xcount; //pret_video
    if xsupport = '5' then
      pret_annee.Fields[6].AsInteger := xcount; //pret_mmedia
    if xsupport = '6' then
      pret_annee.Fields[7].AsInteger := xcount; //pret_autres
    pret_annee.Post;
    ADOQuery1.Next;
  end;
  label24.Visible := True;
  ProgressBar1.Visible := False;
end;
 
procedure TfrmAcqui.archives_prets_BtClick(Sender: TObject);
begin
  Label26.Visible := False;
  ActiveTable(Self);
  ProgressBar1.Visible := True;
  ProgressBar1.Position := 0;
  ProgressBar1.Max := Table029.RecordCount;
  Table029.First;
  while not Table029.Eof do
  begin
    FindLect(Table029.Fields[19].AsString); //id_lecteur
    if id_lect <> '0' then
    begin
      if expl.Locate('N_Inventaire', Table029.Fields[0].AsString, [loCaseInsensitive]) then
      begin
        archives_prets.Append;
        archives_prets.Fields[8].AsString := expl.Fields[3].AsString; //id_notice
        notices.Filter := 'ID_Notice=''' + expl.Fields[3].AsString + '''';
        notices.Filtered := True;
        archives_prets.Fields[9].AsString := notices.Fields[1].AsString; //titre
        if langue.Locate('Id_Langue', notices.Fields[2].AsString, [loCaseInsensitive]) then
          archives_prets.Fields[10].AsString := langue.Fields[2].AsString; //langue
        archives_prets.Fields[11].AsString := notices.Fields[5].AsString; //vedette
        archives_prets.Fields[12].AsString := notices.Fields[9].AsString; //type_xsupport
        archives_prets.Fields[26].AsString := notices.Fields[7].AsString; //type_ved
 
        if notices.Fields[7].AsString = '1' then
        begin
          if not_ved.Locate('ID_Notice', expl.Fields[3].AsString, [loCaseInsensitive]) then
            archives_prets.Fields[25].AsString := not_ved.Fields[2].AsString; //id_ved
        end
        else if notices.Fields[7].AsString = '2' then
        begin
          if ved_col.Locate('Collectivite', notices.Fields[5].AsString, [loCaseInsensitive]) then
            archives_prets.Fields[25].AsString := ved_col.Fields[0].AsString; //id_ved
        end;
        archives_prets.Fields[13].AsString := expl.Fields[0].AsString; //id_expl
        if cotes.Locate('ID_Cote', expl.Fields[4].AsString, [loCaseInsensitive]) then
          archives_prets.Fields[14].AsString := cotes.Fields[1].AsString; //cote
        if bullet.Locate('ID_Expl', expl.Fields[0].AsString, [loCaseInsensitive]) then
        begin
          archives_prets.Fields[15].AsString := bullet.Fields[3].AsString; //fascicule
          archives_prets.Fields[24].AsString := bullet.Fields[0].AsString; //id_bul
        end;
        archives_prets.Fields[23].AsString := Table029.Fields[0].AsString; //n_inventaire
        if lecteurs.Locate('Id_Lect', id_lect, [loCaseInsensitive]) then
        begin
          archives_prets.Fields[1].AsString := id_lect;
          archives_prets.Fields[2].AsString := lecteurs.Fields[5].AsString; //nom_lect
          archives_prets.Fields[3].AsString := lecteurs.Fields[6].AsString; //prenom_lect
          archives_prets.Fields[4].AsString := lecteurs.Fields[2].AsString; //type_lect 1:pers;2:collec
          archives_prets.Fields[5].AsString := lecteurs.Fields[3].AsString; //type_public 1:ad;2:enf
          archives_prets.Fields[6].AsString := lecteurs.Fields[7].AsString; //datenais
          archives_prets.Fields[7].AsString := lecteurs.Fields[48].AsString; //civilité
          archives_prets.Fields[19].AsString := lecteurs.Fields[43].AsString; //id_csp
          if csp.Locate('ID_csp', lecteurs.Fields[43].AsString, [loCaseInsensitive]) then
            archives_prets.Fields[20].AsString := csp.Fields[1].AsString; //lib_csp
        end;
        archives_prets.Fields[21].AsString := '1'; //id_bib
        if pret.Locate('Id_Lecteur;Id_Expl', VarArrayOf([id_lect, expl.Fields[0].AsString]), [loCaseInsensitive]) then
        begin
          archives_prets.Fields[16].AsString := pret.Fields[0].AsString; //id_pret
          archives_prets.Fields[17].AsString := pret.Fields[3].AsString; //date_pret
          archives_prets.Fields[18].AsString := pret.Fields[4].AsString; //date_retour
        end
        else
        begin
          archives_prets.Fields[17].AsString := Table029.Fields[2].AsString; //date_pret
          archives_prets.Fields[18].AsString := Table029.Fields[15].AsString; //date_retour
          archives_prets.Fields[21].AsString := '1'; //pret.Fields[8].AsString; //id_bib
        end;
        if not_edi.Locate('ID_Notice', notices.Fields[0].AsString, [loCaseInsensitive]) then
        begin
          archives_prets.Fields[28].AsString := not_edi.Fields[2].AsString; //id_edi
          if editeurs.Locate('Id_Edi', not_edi.Fields[2].AsString, [loCaseInsensitive]) then
            archives_prets.Fields[27].AsString := editeurs.Fields[1].AsString; //editeur
        end;
        if not_ens.Locate('ID_Notice', notices.Fields[0].AsString, [loCaseInsensitive]) then
        begin
          archives_prets.Fields[30].AsString := not_ens.Fields[2].AsString; //id_tens
          if ens.Locate('Id_Ens', not_ens.Fields[2].AsString, [loCaseInsensitive]) then
            archives_prets.Fields[29].AsString := ens.Fields[1].AsString; //titre_ens
          archives_prets.Fields[31].AsString := not_ens.Fields[3].AsString; //tome
        end;
        if stitres.Locate('ID_Notice', notices.Fields[0].AsString, [loCaseInsensitive]) then
          archives_prets.Fields[32].AsString := stitres.Fields[1].AsString; //sous_titre
        archives_prets.Post;
      end;
    end;
    ProgressBar1.Position := ProgressBar1.Position + 1;
    Table029.Next;
  end;
Voilà, je suis sous Delphi7, mysql avec ODBC.
Merci de m'aider le plus vite possible, c'est très très urgent. Mon Client attend et je dois finir aujourd'hui de l'installer.
Merci d'avance.
[Balises CODE rajoutées par Pedro. Merci d'y penser à l'avenir]