Bonjour,

Voila j'ai crée une petit appli pour la mise du plan comptable. Sur ma fiche j'ai trois DBgrid rattaché à 3 datasources.

Mon code fonctionne, mais sur l'xecution il n'est pas trés rapide

voila 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
 
function TFic_MAJ_compte.SimilitudeCpte(Cpte : integer; Lettre : String):Boolean;
var
   i : integer;
   Trouve : Boolean;
begin
     i := length(IntToStr(Cpte));
     Trouve := False;
     repeat
          if (Query_CTRctrnum.AsString = copy(IntToStr(Cpte),0,i)) and (Query_CTRctrlbu.AsString = Lettre)then Trouve:= True;
          i := i - 1;
     until not (i = 2) or (trouve);
     Result := Trouve;
end;
 
procedure TFic_MAJ_compte.Button1Click(Sender: TObject);
Var
   I, Max : Integer;
   Trouve : Boolean;
begin
     //Query_erreur.Last;
     Max := Query_erreur.RecordCount;
     ProgressBar1.Max := Max;
     //Query_erreur.First;
     I := 0;
     While not Query_erreur.Eof do
     begin
          // Gestion de la barre de progression
          ProgressBar1.Position := i + 1 ;
          Label5.Caption := IntToStr(i) + '/'  + IntToStr(Max) + ' compte(s)';
          Application.ProcessMessages;
          Query_CTR.First;
          Trouve := False;
          while not Query_CTR.eof and not trouve do
          begin
               Trouve := SimilitudeCpte(Query_erreurctonum.AsInteger,Query_erreurctolbu.AsString);
               if Trouve then
               begin
                    Query_General.SQL.Clear;
                    Query_General.SQL.Add('update Compte_ordonnateur set ctrser = ' + Query_CTRctrser.AsString + ' where ctoser = ' +
                                           Query_erreurctoser.AsString);
                    Query_General.ExecSQL;
                    Memo_Modification.lines.add(Query_CTRctrnum.AsString + ' ' + Query_erreurctonum.AsString + ' ' + Query_erreurctolbu.AsString + ' ' + Query_erreurctoexe.AsString);
               end;
               Query_CTR.Next;
          end;
          Query_erreur.Next;
          i := i + 1;
          //if Query_erreurctonum.AsInteger = 158 then break ;
     end;
end;
Si vous avez une idée pour un execution plus rapide, je suis preneur.

MERCI.
Valoji