ifADIQeuery3.SQL:='select count(*) from count3 where V_DTime=:DTime';Showmessage(inttostr(ifADOQuery3.Fields.Fields[0].Value ));
if ifADOQuery3.IsEmpty then
     begin
     // ifADOQuery3.Close;
      inster3ADOQuery.Parameters.ParamByName('Site_ID').Value:=Site_ID;
      inster3ADOQuery.Parameters.ParamByName('V_DTime').Value:=V_DTime;
      inster3ADOQuery.Parameters.ParamByName('V_View').Value:=V_View;
      inster3ADOQuery.Parameters.ParamByName('V_IP').Value:=V_IP;
      inster3ADOQuery.ExecSQL;
      Showmessage('NULL'+inttostr(Site_ID)+inttostr(V_View)+inttostr(V_IP)+datetimetostr(V_DTime));
      m:=m+1;
      TeLabel2.Caption:='正在导入表3(View)中的第'+inttostr(m)+'条记录,稍等...';
     end
      else
...明明我的Count3中没有任何记录,但为什么Showmessage(inttostr(ifADOQuery3.Fields.Fields[0].Value ));总是返回1呢??我用的是ACCSEE

解决方案 »

  1.   

    试试
    Showmessage(ifADOQuery3.Fields.Fields[0].AsString);
      

  2.   

    把ifADOQuery3.RecordCount读出来看是多少。
      

  3.   

    Showmessage(inttostr(ifADOQuery3.Fields.Fields[0].AsInteger ));
    显示的倒是正常了~~~但为什么会这样呢???难到ifADOQuery3.IsEmpty 不能判断吗?
      

  4.   

    .asstring 
    or  sql 语句
      

  5.   

    Showmessage(inttostr(ifADOQuery3.Fields.Fields[0].Value ));
    if ifADOQuery3.IsEmpty then你showmessage在IsEmpty 前面,它怎么判断呢要不你if ifADOQuery3.IsEmpty then换成
    if ifADOQuery3.RecordCount=0 then
      

  6.   

    我在if ifADOQuery3.IsEmpty then前面有下面的语句的~~ifADOQuery3.Open;if ifADOQuery3.IsEmpty then
      

  7.   

    Showmessage(inttostr(ifADOQuery3.Fields.Fields[0].AsInteger ));的结果为0,但它为什么进入if ifADOQuery3.IsEmpty then去执行里面的内容呢?
      

  8.   

    你用dataset.fields的asinteger的时候,当你记录为空,他会返回为0,
    所以,Showmessage(inttostr(ifADOQuery3.Fields.Fields[0].AsInteger ))的结果为0
    并不能证明有记录,你可以试试一个空表,用Showmessage(inttostr(ifADOQuery3.Fields.Fields[0].AsInteger )),你会发现它也是0
      

  9.   

    我晕,select count(*) 永远会返回一个字段,一行数据的结果集,如果表是空的,就是0啊,
    它是用来读表的数据记录的啊,faint
      

  10.   

    那么SQL语句是不是要这样写:
    'select count(*) from count3 where V_DTime=:DTime';
      

  11.   

    上面的写错了~~
    那么SQL语句是不是要这样写:
    'select * from count3 where V_DTime=:DTime';
      

  12.   

    count(*)当然会有一行数据返回了,如果没有满足条件的记录就会返回0,有满足条件的记录就返回满足条件的实际数
    它永远返回一条记录象你这样showmessage出来后,若表中没有满足你条件的记录,当然会显示0了不要用count(*)呀,直接用select * from .....就可以了
      

  13.   

    当然是1了,这条语句永远只有一条记录ADOQeuery3.SQL:='select count(*) as cc from count3 where V_DTime=:DTime';...showmessage(Adoquery3.fieldbyname('cc').asstring);
      

  14.   


    用ADOQeuery3.RENO
    或ADOQeuery3.RecordCount都不行我就得关注了!!