如何返回用Query查询得到的记录条数?

解决方案 »

  1.   

    Query.RecCount;最好使用select count(*) from xxx 来返回记录数,上面的可有些数据库不支持
      

  2.   

    我试过RecordCount但是不行,而且我要查询的是根据条件得到的实际记录数
      

  3.   

    recordcount就是你的查询结果啊!!!
      

  4.   

    这是我的源代码:  
      Query1.Active:=false;
      Query1.SQL.Clear;
      Query1.SQL.Add('select * from Tb_JKinfo where JK_ID=12');
      Query1.Prepare;
      Query1.Open;  i:= Query1.RecordCount;
      showmessage(inttostr(i));
    返回值始终是-1;
      

  5.   

    有RecordCount属性,为什么不用?
      

  6.   

    这样应该就可以了
      Query1.Active:=false;
      Query1.SQL.Clear;
      Query1.SQL.Add('select * from Tb_JKinfo where JK_ID=12');
      Query1.Prepare;
      Query1.Open;
      Query1.last;  i:= Query1.RecordCount;
      showmessage(inttostr(i));