[Student information management system] EOF and BOF, eofbof

Source: Internet
Author: User

[Student information management system] EOF and BOF, eofbof

When the student information management system is knocked out, such errors often occur when information is deleted, and the problem must be solved. After reading and understanding the EOF and BOF attributes of Recordset, you can use these two attributes to know whether information exists in the record set.

EOF and BOF attributes

  • BOF indicates that the current record is located before the first record of the Recordset object.
  • EOF indicates that the current record is located after the last record of the Recordset object.

Return Value: Boolean value is returned for the BOF and EOF attributes.


The BOF and EOF attributes can be used to determine whether the Recordset object contains records or whether the record exceeded when it is moved from one record to another.

Out of the Recordset object restrictions.

  • If the current record is before the first record, the BOF attribute returns True. If the current record is the first record or is after it, False is returned.
  • If the current record is located in the last record of the Recordset object, the EOF attribute returns True, and the current record is the last record of the Recordset object or is located before it, False is returned.
  • If the BOF or EOF attribute is True, no current record exists.

If no Recordset object is opened, the BOF and EOF attributes are set to True, while the Recordset object's RecordCount attribute is set

Set to zero. When you open a Recordset object that contains at least one record, the first record is the current record, and the BOF and EOF attributes are False.


If you delete the last record in the Recordset object, the BOF and EOF attributes remain False until the current record is rescheduled.


The following table describes the moving methods allowed by the combination of BOF and EOF attributes.

The error is caused by the error in the figure below when the code is executed.

 

MoveFirst,

MoveLast

MovePrevious,

Move <0

Move 0

MoveNext,

Move> 0

BOF = True,

EOF = False

Allow

Error

Error

Allow

BOF = False,

EOF = True

Allow

Allow

Error

Error

True at the same time

Error

Error

Error

Error

False at the same time

Allow

Allow

Allow

Allow

 

The use of the Move method does not guarantee that the method is successfully located, but does not produce errors when the specified Move method is called.

The following table describes how BOF and EOF attribute settings occur when various Move methods are called but records are not successfully located.

 

 

BOF

EOF

MoveFirst, MoveLast

Set to True

Set to True

Move 0

No changes

No changes

MovePrevious, Move <0

Set to True

No changes

MoveNext, Move> 0

No changes

Set to True



What is EOF and BOF?

BOF indicates that the current record is located before the first record of the Recordset object. EOF indicates that the current record is located after the last record of the Recordset object. When RecordCount0 is enabled, both BOF and EOF return True values BOF and EOF attributes return boolean values. The BOF and EOF attributes can be used to determine whether a Recordset object contains a record, or whether the restriction on the Recordset object is exceeded when a record is moved from one record to another. If the current record is located before the first record, the BOF attribute returns True (-1). If the current record is the first record or is located later, False (0) is returned ). If the current record is located in the last record of the Recordset object, the EOF attribute returns True, and the current record is the last record of the Recordset object or is located before it, False is returned. If the BOF or EOF attribute is True, no current record exists. If no Recordset object is opened, the BOF and EOF attributes are set to True, and the RecordCount attribute of the Recordset object is set to zero. When you open a Recordset object that contains at least one record, the first record is the current record, and the BOF and EOF attributes are False. If you delete the last record in the Recordset object, the BOF and EOF attributes remain False until the current record is rescheduled.

BOF and EOF

When you use ADO to connect to the database for query, the database returns the query results to the query end. A list is displayed in the memory of the query end, which stores the query results. The list in this memory is the dataset. In your program, rs indicates this dataset. Bof indicates that the current pointer of rs is before the dataset. For example, there are four records numbered 1, 2, and 4 in the dataset, but rs points to the number-1, this will meet the bof situation. Similarly, when the rs Pointer Points to 5, but the fifth record does not exist, this will produce an eof.

If bof and aof are generated at the same time, that is to say, the rs pointer is both out of the upper bound and out of the next session. In this case, the dataset represented by rs is empty, in this way, the rs pointer has both bof and eof attributes, no matter where it is.

Your estimation is that the value queried by the SQL statement is empty, so the dataset is empty. This error is reported when you read the value in the rs dataset.
Use if rs. bof and rs. the eof then judgment can determine whether there is a dataset in rs. If this condition is met, the dataset is empty, and access to the fields in rs should be bypassed in the program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.