Einzelnen Beitrag anzeigen

danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#8

AW: Counting in a database table

  Alt 30. Nov 2012, 11:31
first it might be better to use Integer-Fields thean String Fields, to avoid double counting.

second all Fields inthe Table should be defined and knowed, so you better use a Query like

Delphi-Quellcode:

        for I := Table.FieldDefs.Count -1 downto 2 do
        begin
          case Table.FieldByName(Table.FieldDefs[i].Name).AsInteger of
            1 : begin
                  cnt1:= cnt1 + 1;
                  Label1.Caption := IntToStr(cnt1) + ' x';
                  Application.ProcessMessages;
                end;
           10 : begin
                  cnt10 := cnt10 + 1;
                  Label2.Caption := IntToStr(cnt10) + ' x';
                  Application.ProcessMessages;
                end;
K-H
Thank you, now it counts quickly and correctly.
I somehow forgot the Case:
Daniel
  Mit Zitat antworten Zitat