Home > Software engineering >  VB6.0 by use of database programming BOF, EOF doesn't work is why?
VB6.0 by use of database programming BOF, EOF doesn't work is why?

Time:09-21

 Set conn=New ADODB. Connection 
Set the rs=New ADODB. You
Conn. Open the Provider="Microsoft. Jet. The OLEDB. 4.0; Data Source="& amp; App. The Path & amp; "\ jsyxxgl MDB
"Rs. Open the "select * from Main_User", conn, 2, 2


 Private Sub Command3_Click () 
If the rs. EOF Then
MsgBox "is that at the end of the record", 48, "record browse
"The Else
Rs. MoveNext
The Call display
End the If
End Sub


This program is written according to the tutorial I, problem is out of here, 3021 real-time mistakes, I am a novice, hope to have a great god can solve this problem, thank you very much ~ ~ ~
Source: http://pan.baidu.com/s/1geM4yZp

CodePudding user response:

1) with the client cursor
 Set conn=New ADODB. Connection 
Set the rs=New ADODB. You
Conn.=adUseClient 'CursorLocation & lt; -
Conn. Open the Provider="Microsoft. Jet. The OLEDB. 4.0; Data Source="& amp; App. The Path & amp; "\ jsyxxgl MDB
"Rs. Open the "select * from Main_User", conn, 2, 2

2) rs. Open after the judge whether the record is empty, if is empty Command3 cannot operation,

CodePudding user response:

@ Tiger_Zhao the BOF or decide not to come out, had been False is the code I have been wrong?

CodePudding user response:

BOF, EOF attributes (ADO)


BOF indicating the current record position is located in you object before the first record,


EOF indicating the current record position is located in the object you after the last record,
The return value

BOF and EOF property returns the Boolean values,

Description

Use of BOF and EOF attribute can be set for you whether the object contains records, or from one record to another record is beyond the limit of you object,

If the current record is located in the first, before BOF property returns True (1), if the current record is the first or the thereafter, returns False (0),

If the current record is located in you after the last record EOF property returns True, and the current record is the last record you object or located in the former, it will return False,

If BOF or EOF is attribute to True, then there is no current record,

Open if there is no record of you object, BOF and EOF attributes will be set to True, and you object RecordCount property is set to zero, open contains at least one record of you object, the first record for the current record, and BOF and EOF attribute to False,

Delete if you object to retain the last record of BOF and EOF attribute will remain False, until to reschedule the current record,

The following table shows different BOF and EOF attributes combination is allowed to Move method,

MoveFirst,
MoveLast MovePrevious,
Move & lt; 0
Move 0 MoveNext,
Move & gt; 0
BOF=True,
EOF=False wrong mistake to allow
BOF=False,
EOF=True to allow for error error
At the same time to True error errors error
At the same time to False allows to allow allow


Allows you to use Move method does not guarantee that this method is successful positioning record, just means to invoke the specified Move method don't generate errors,

The following table shows that when the Move method but failed to locate records in BOF and EOF attribute set what happened,

BOF EOF
MoveFirst, MoveLast is set to True is set to True
Move 0 no change no change
MovePrevious, Move & lt; 0 is set to True no change
MoveNext, Move & gt; 0 no change is set to True

CodePudding user response:

 Private Sub Command3_Click () 
Rs. MoveNext

If the rs. EOF Then
MsgBox "is that at the end of the record", 48, "record browse
"The Else
The Call display
End the If
End Sub

CodePudding user response:

You understanding of EOF and designers, in their view, on the last record, not EOF, only over the last record, reached the EOF, EOF property is valid,
  • Related