C
crownboy
Unregistered / Unconfirmed
GUEST, unregistred user!
今天写了下列的代码
var
ColumnName,sqlstr:String;
ColumnTotal:Integer;
begin
with TADOQuery.Create(nil) do
begin
Connection := Form1.ADOConnection1;
try
close;
sql.Clear;
sql.Add('select * from 人才数据库');
open;
ColumnName := fields.Fields[1].FieldName;
sqlstr := 'select count(distinct '''+ColumnName+''') as '''+ColumnName+''' from 人才数据库';
sql.Clear;
sql.Add(sqlstr);
open;
ColumnTotal := fieldbyname(ColumnName).Value;
LabeledEdit1.Text := inttostr(ColumnTotal);
finally
free;
end;
end;
end;
LabeledEdit1.Text的值 总是显示 1 当我把 distinct 去掉后 就能显示正确的行数,但是我现在要的是唯一值的个数,问题是出在什么地方??
var
ColumnName,sqlstr:String;
ColumnTotal:Integer;
begin
with TADOQuery.Create(nil) do
begin
Connection := Form1.ADOConnection1;
try
close;
sql.Clear;
sql.Add('select * from 人才数据库');
open;
ColumnName := fields.Fields[1].FieldName;
sqlstr := 'select count(distinct '''+ColumnName+''') as '''+ColumnName+''' from 人才数据库';
sql.Clear;
sql.Add(sqlstr);
open;
ColumnTotal := fieldbyname(ColumnName).Value;
LabeledEdit1.Text := inttostr(ColumnTotal);
finally
free;
end;
end;
end;
LabeledEdit1.Text的值 总是显示 1 当我把 distinct 去掉后 就能显示正确的行数,但是我现在要的是唯一值的个数,问题是出在什么地方??