Recently, I knocked on a small exercise project, the student information management system, which encountered some problems during the debugging process. Through these questions, I learned a lot of new knowledge, today, I want to record the "real-time error '123456'". I believe most people will encounter this problem when they first use VB to connect to the database. How to solve the real-time error "3021? Let's take a look at what EOF and BOF are.
When you use the ADO database for query, when you return the database query results to the query end, a list is displayed in the memory of the query end, which stores the query result set. Let's assume that MRC is a dataset, and 1, 2, 3, and 4 are the four data in the dataset, for example:
We can clearly see that when MRC points to number-1, this is in line with BOF; when it points to 5 (this record does not exist), this is the case of EOF. If BOF and EOF occur at the same time, that is, the pointer is both out of the upper and lower bounds, which indicates that the dataset is empty.
Cause of this error: 1. The database record we searched for is empty;
2. After finding the data, use the del command to delete the record and then reference fields;
3. The movefirst or moveprevious command has been used to start the mobile database and then run the moveprevious command;
4. You have used movelast or the movenext command to move it to the last location of the database and then use the movenext command.
Solution:
If there is no data in the queried table, we can add an error:
On Error resume nextmrc. movefirstif err = 3021 then response. Write "no data! "End if
When we delete the last record, this problem also occurs when fields is referenced. You can refer to the following code:
Private sub register delete_click () dim intmsgbox as integer m_vntbookmark = m_rstcourseinfo.bookmark intmsgbox = msgbox ("Do you want to delete the current record? ", Vbokcancel," delete current record ") if intmsgbox = vbok then if m_rstcourseinfo.eof = true then deleted if then = true then m_rstcourseinfo.delete msgbox" the last record is deleted, the record is empty! ", Vbokonly + vbexclamation, "Warning" unload me else upload m_vntbookmark = {}}}}= m_vntbookmark call viewdata end if else m_vntbookmark = {}}}= m_vntbookmark call viewdata end if else = m_vntbookmark call viewdata end if end sub
Further sorting will be published in the following blogs. I hope you will pay attention to it!