怎样判断ADOQuery数据集中的记录数是否为空,也就是判断数据集中是否有数据?...

怎样判断ADOQuery数据集中的记录数是否为空,也就是判断数据集中是否有数据? Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiDB/html/delphi_20061221094018194.html
rt

ADOQuery.Open;  
  if   ADOQuery.Eof   then  
      数据为空  
 

ADOQuery1.Open;    
    if   ADOQuery1.IsEmpty   then

ADOQuery1.Open;    
    if   ADOQuery1.RecordCount<=0   then     数据为空  
 

ADOQuery1.Open;    
    if   ADOQuery1.IsEmpty   then  
  正解  
   
  不能以RecordCount为判断条件

if   ADOQuery.Eof   then  
  与  
  if   ADOQuery1.IsEmpty   then  
  这两个哪个更好一些?

if   ADOQuery1.IsEmpty   then   这个把握大些,不会出错。不依赖于其它的状态,只要ADOQuery1打开了就可以。Is译为是,Empty对为空,联系起来是:是空。    
  ADOQuery.Open;  
  //如果在AfterOpen事件里进行了操作,可能会导致判断不准确。  
  if   ADOQuery.Eof   then

1、ADOQuery1.RecordCount   是否为0  
  2、ADOQuery1.IsEmpty   是否为true  
  3     if   ADOQuery.bof=ADOQuery.eof   then   没记录  
        else   有!

转载于:https://www.cnblogs.com/delphi2007/archive/2008/12/11/1352535.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值