Hello.
I need advice on how to count multiple entries in a database table from the third column to the last column in the whole table.
I need to count how many times the table number 1 and 10.
I use this code and it is not good:
Delphi-Quellcode:
procedure Tfrm_main._NE;
var
i,y: integer;
begin
Application.ProcessMessages;
with Table do
begin
DisableControls;
y := 0;
try
First;
while not EOF do
begin
for I := Table.FieldDefs.Count -1 downto 2 do
begin
if Pos('1', Table.FieldByName(Table.FieldDefs[i].Name).AsString) > 0 then
begin
y := y + 1;
Label1.Caption := IntToStr(y) + ' x';
Application.ProcessMessages;
end;
if Pos('10', Table.FieldByName(Table.FieldDefs[i].Name).AsString) > 0 then
begin
y := y + 1;
Label2.Caption := IntToStr(y) + ' x';
Application.ProcessMessages;
end;
end;
Next;
Application.ProcessMessages;
end;
finally
EnableControls;
Application.ProcessMessages;
end;
end;
The result is always the same!