我用recordcount来检测,结果query明明是空检测出来recordcount却为1.请问为什么?该如何检测?

解决方案 »

  1.   

    procedure TForm1.Button4Click(Sender: TObject);
    var
    vsql:string;
    begin
    vsql:='select * from insys';
    with query1 do
    begin
      close;
      sql.clear
      SQl.add(vsql);
      open;
    end;
    if query1.recordcount>0 then
    showmessage('the table is not empty')
    else showmessage('the table is empty');end;
      

  2.   

    用select count(*) as jlsh from.....
      

  3.   

    isEmpty:Boolean;
    isEmpty:=ADOQuery1.IsEmpty;
    if isEmpty then
    begin
    showmessage('the table is not empty');
    end;
    else
    begin
     showmessage('the table is empty');
    end;
      

  4.   

    支持 WbtServer !
    就用IsEmpty屬性檢查是否為空
      

  5.   

    我的源码:select max(rq),min(rq) form table where (rq<:maxrq) and (rq>:minrq)
    注:rq为日期型字段名,minrq,maxrq为日期型参数,明明查出来的记录为空,但始终显示recordcount=1.
      

  6.   

    Query.close;
    Query.sql.text='select * from table1';
    query.open;
    if query.isEmpty then
    showmessage('The table1 is empty');
      

  7.   

    我以前用MAX和MIN的时候也出现了这样的问题。关注。
      

  8.   

    建议你把SQL语句改改试试。可以分别检索,再取第一条记录和最后一条记录就可以了。
      

  9.   

    以前我用adoquery的时候也有这种问题,采用webserver的方法就ok了
      

  10.   

    if Query.eof and Query.bof then
    begin
    end
    else if 
    ..........
      

  11.   

    if Query.IsEempty = false then
    begin
    //Query不为空时
    end;
      

  12.   

    max() min()总要返回一个值的,所以结果集不会是空的
      

  13.   

    4242......
    用select count(*) as num from...算出来的数目总是不正确的.num的值总是几十万的数啊......
      

  14.   

    如果返回值不能为空,哪我用什么方法来判断我的Query是否为空?
      

  15.   

    if Query1.IsEmpty then
    //Query1是不是为空
      

  16.   

    也许你应该分清楚Query为空(没有符合条件的记录)和
    max(rq)(没有符合条件的字段值)为空是不同的两回事.
      

  17.   

    如果为空,返回为 '',
    今天我也遇上了,在csdn上解决了
    建议参考:http://expert.csdn.net/Expert/topic/1539/1539558.xml?temp=.1986353