CRecordset::IsBOF和CRecordset::IsEOF

CRecordset::IsBOFCRecordset::IsEOF

IsBOF

作用:如果记录集定位于第一个记录之前,返回非零。此时没有当前记录。

BOOL IsBOF( ) const;

返回值:

如果记录集没有记录,或者你已经向前游动到第一个记录之前,则返回非零;否则返回0.

Remarks


Call this memberfunction before you scroll from record to record to learn whether you have gonebefore the first record of the recordset. You can also useIsBOF alongwith IsEOFto determine whether the recordset containsany records or is empty. Immediately after you callOpen, if therecordset contains no records, IsBOF returns nonzero.When you open arecordset that has at least one record, the first record is the current recordandIsBOF returns 0.

在你逐个记录滚动之前,访问这个成员函数来获悉是否已经滚动到记录集第一个记录的前面。你也可以结合使用IsBOF和IsEOF来决定记录集是否包含记录或者为空。在访问Open函数之后,如果记录集没有任何记录,IsBOF返回非零。当你打开一个至少包含一个记录的记录集,第一个记录是当前记录,此时IsBOF返回0.

If the firstrecord is the current record and you callMovePrev, IsBOF willsubsequently return nonzero. IfIsBOF returns nonzero and you call MovePrev,an error occurs. IfIsBOF returns nonzero, the current record isundefined, and any action that requires a current record will result in anerror.

如果第一个记录是当前记录并且你访问MovePrev,之后IsBOF会返回非零值。如果IsBOF返回非零值并且访问MovePrev函数,会报错。如果IsBOF返回非零值,说明当前记录没有定义,任何请求当前记录的动作将会导致错误。

IsEOF

作用:如果记录集定位到最后一个纪录之后,返回非零。此时,没有当前记录。

BOOL IsEOF( ) const;

返回值

如果记录集没有记录,或者你已经滚动到最后一条纪录之后,则返回非零。否则,返回0.

Call this member function asyou scroll from record to record to learn whether you have gone beyond the lastrecord of the recordset. You can also useIsEOF to determine whether therecordset contains any records or is empty. Immediately after you callOpen, if therecordset contains no records, IsEOFreturns nonzero. When you open a recordset that has at least one record, thefirst record is the current record andIsEOFreturns 0.

If the last record is thecurrent record when you callMoveNext,IsEOFwill subsequently return nonzero. IfIsEOFreturns nonzero and you call MoveNext,an error occurs. IfIsEOFreturns nonzero, the current record is undefined, and any action that requiresa current record will result in an error.

Example

// Open a recordset; firstrecord is current

CCustomerrsCustSet(&m_dbCust);

rsCustSet.Open();

 

if(rsCustSet.IsBOF())

   return;

   // The recordset is empty

 

// Scroll to the end of therecordset, past

// the last record, so norecord is current

while (!rsCustSet.IsEOF())

   rsCustSet.MoveNext();

 

// Move to the last record

rsCustSet.MoveLast();

 

// Scroll to beginning of therecordset, before

// the first record, so norecord is current

while(!rsCustSet.IsBOF())

   rsCustSet.MovePrev();

 

// First record is currentagain

rsCustSet.MoveFirst();

 

 

 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值