dbgrid中没有记录, 我定义了双击事件 双击时发生错误 我怎么判断记录是否为空!

解决方案 »

  1.   

    with DataSource.DataSet do
        if not (Eof and Bof) then
           if not FieldByName('字段').IsNull then
           begin
             // 你的代码
           end;
      

  2.   

    看 if (dbgrid.datasource.dataset.active) and (dbgrid.datasource.dataset.recordcount>0) then showmessage('记录不空');
      

  3.   

    if dbgrid1.datasource.dataset.recordcount>0 then
      

  4.   

    我认为 用dataset.recordcount>0 不太好,如果是Query,其中的sql语句有sum,那么dataset.recordcount>0 总是成立的,
    我推荐用 fancier(OP&&C/C++) 的
            if not FieldByName('字段').IsNull then
      

  5.   

    flp(会说话的哑巴) 说得很对,sum可能返回空值,所以最好用not fieldbyname('').isNull来判断
      

  6.   

    if not DataSet.Active then Exit;
    if DataSet.IsEmpty then Exit;