cool hit counter Exploring BOF and EOF_Intefrankly

Exploring BOF and EOF


Copyright: This is an original post by the blogger and may not be reproduced without the blogger's permission. https://blog.csdn.net/huyuyang6688/article/details/9533055

After knocking out the Student Information Management System, the mere presence of new terms when you were new to databases before could stir your brain like mush. After the baptism of the Red Book and the Student Information Management System, I have a much deeper understanding of the knowledge involved in the database than when I first encountered it a few months ago, as is the case with two attributes that are not very visible but play an important role - BOF and EOF.

The first encounter with them was when I was knocking around the Red Book, but at the time, I had a distorted understanding of their usage and didn't pay much attention to them until I discovered their importance in the course of the Student Information Management System.

BOF and EOF are a pair of properties of the Recordset (recordset) object that return values of type Boolean.

BOF points to the first record whose current record position is in the Recordset object prior to ; EOF points to the last record whose current record position is in the Rocordset object later。 note BOF does not mean that the current record position is in the first record of the Recordset object, and similarly EOF does not mean that the current record is in the last record of the Recordset object.

The following two pieces of code provide a good illustration.

Correct code.

private sub nextCommand_Click()
      mrc.MoveNext     'mrcfor a recordset object
      If mrc.EOF then
            mrc.MoveFirst
      End if
      Call viewData    'viewData for a function that displays the current record on a form
End sub

Error code.

private sub nextCommand_Click()
      If mrc.EOF then
           mrc.MoveFirst
      Else
           mrc.MoveNext     'mrcfor a recordset object
      End if
      Call viewData    'viewData for a function that displays the current record on a form
End sub

This code achieves the function of displaying the next record, and the correct way to do this is to have the record move down first (regardless of whether the current record is the last one), which can actually be done by giving the current record a pointer on a gauge , think of the records in the database as memory addresses, and when the pointer after the downshift points to the last address block later When (i.e., after moving down, the record if pointing after the last record), the return value of EOF is True.

In order to understand more clearly, a diagram (as shown on the right) is drawn to explain EOF and BOF, assuming that there are a total of n records in the record set, when the current record pointer points to the first record before, the BOF attribute value is True; when the current record points to any of the records from 1 to n in the middle, the BOF and EOF attribute values

are False; EOF when the current record points after the last record

attribute value is True.

Of course, EOF and BOF together can also perform functions such as.

When the judgment statement BOF And EOF, if the result is True, i.e., both of them return True, it indicates that there is no record in the current record set; and when there is only one record in the record and at that record position, the return value of BOF and EOF are both False.


Recommended>>
1、Swiss Franc FRCoin recreating another myth beyond Bitcoin in the cryptocurrency world
2、WeChat Red Packet Fryer Cheats Red Packet Fryer Hanging Out WeChat Red Packet Auxiliary Perspective Software
3、The best vehicle for artificial intelligence is either a smartphone
4、Machine Learning Artificial Learningweekly 2018729
5、Racer Technology resolutely crack down on pornography zero tolerance for illegal and harmful content

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号