var CountField:Integer;with Query1 do begin Close; DatabaseName:=DatabaseName; SQL.Clear; SQL.Add('select Count(Field) as CountField From Table'); Open; end;CountField:=Query1.FieldByName('CountField').AsInteger;
这样 var count:integer; with Query1 do begin if Active then Close; SQL.Text:='select Count(*) as Result from TableName {where }'; Open; count:=FieldByName('Result').value; end; 如果支持recordcount属性,则直接这样var count:integer; with Query1 do begin if Active then Close; SQL.Text:='select * from TableName {where }'; Open; try count:=RecordCount; except count:=0; end; end;
执行这条SQL语句 ‘select Count(*) as cnt from tablename'然后 COUNT :=Query.FieldbyName(cnt).AsInteger;就搞定了
编个循环: query.first; i:=1000; j:=0; repeat l:=query.moveby(i); until l<>i; l:=j*i+l;
CountField:Integer;with Query1 do
begin
Close;
DatabaseName:=DatabaseName;
SQL.Clear;
SQL.Add('select Count(Field) as CountField From Table');
Open;
end;CountField:=Query1.FieldByName('CountField').AsInteger;
var count:integer;
with Query1 do
begin
if Active then
Close;
SQL.Text:='select Count(*) as Result from TableName {where }';
Open;
count:=FieldByName('Result').value;
end;
如果支持recordcount属性,则直接这样var count:integer;
with Query1 do
begin
if Active then
Close;
SQL.Text:='select * from TableName {where }';
Open;
try
count:=RecordCount;
except
count:=0;
end;
end;
‘select Count(*) as cnt from tablename'然后
COUNT :=Query.FieldbyName(cnt).AsInteger;就搞定了
query.first;
i:=1000;
j:=0;
repeat
l:=query.moveby(i);
until l<>i;
l:=j*i+l;