delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
怎样判断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   有!

posted on 2008-12-11 10:08 delphi2007 阅读(848) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。