with adoquery1 do
begin
  SQL.text='select count(*) as Num from AAA' +
            'where zhuangtai = '''未完成''';
  Open;
  khtscount:= FieldByName('Num').asInteger;
end;

解决方案 »

  1.   

    adoquery1.SQL.Clear ;  
    adoquery1.SQL.Add ('select * from AAA ');  
    adoquery1.SQL.Add('where zhuangtai='+'''未完成''');  
    adoquery1.Open ;  
    khtscount:=adoquery1.RecordCount   
      

  2.   

    adoquery1.SQL.Clear ;  
    adoquery1.SQL.Add ('select * from AAA ');  
    adoquery1.SQL.Add('where zhuangtai = '+#39 + '未完成'+#39); //注意空格; 
    adoquery1.Open ;  
    adoquery1.First;
    adoqeury1.Last;
    khtscount:=adoquery1.RecordCount ;//不要直接就RecordCount(如果是SQL Server)
      

  3.   

    应该这样,前面有人说对了,用count(*)是很高速的操作:adoquery1.SQL.Clear ;  
    adoquery1.SQL.Add ('select count(*) from AAA ');  
    adoquery1.SQL.Add('where zhuangtai="未完成"');  
    adoquery1.Open ;  
    khtscount:=adoquery1.Fields[0].asinteger; 
    还有,数据库sql可以单/双引号互相陷套就行了,
    不需用两个单引号。。
       
    to ihihonline(小小->充电中……) :
      干嘛又first,又last