Error 3021 ( recordset returns either EOF or BOF is TRUE) 
Author Message
 Error 3021 ( recordset returns either EOF or BOF is TRUE)

Hi!

How should I deal with this error with the recordset returns either EOF
or BOF is TRUE?

ei.

public function isEmpty as boolean
  on error goto hell
  dim rec as adodb.recordset
  dim query as string

  set rec = new adodb.recordset
  query = "SELECT * FROM customer WHERE koc = '" & txtcode.text & "'"
  set rec = con.execute(query)

  do while not rec.eof
     lstcustomer.additem , , rec!koc
     rec.movenext
  loop

  set rec = nothing
  exit function
hell:
  select case err.number
        case 3021
                '
  end select
end function

This is what I did usually, I wonder if I'm doing the right thing. I
need some comments. Thanks

-Kawi



Wed, 26 Dec 2001 03:00:00 GMT
 Error 3021 ( recordset returns either EOF or BOF is TRUE)

Since you are queryng just one table, why not chekc BOF and EOF from the
table, exit if true and if not run the query?

L.P.P.



Thu, 27 Dec 2001 03:00:00 GMT
 Error 3021 ( recordset returns either EOF or BOF is TRUE)
Hi LPP,

as I said: The using it's not effective in a loop. Because the program has
to check every circle the status of the EOF-Flag - that means a request to
the database.
If you have only a few record entries it makes no much difference but ...

Try this and measure the difference:

Dim lCount As Long
Dim i As Long

With rec
    .MoveLast
    lCount = .RecordCount
    .MoveFirst
    For i = 1 To lCount
        lstcustomer.AddItem , , !koc
        .MoveNext
    Next i
End With

cu
Mayk



Thu, 27 Dec 2001 03:00:00 GMT
 Error 3021 ( recordset returns either EOF or BOF is TRUE)
Good Morning Mayk
Yes I'm with you, but you must test for the BOF and EOF first, else if the
rs is empty when you movelast you get an error.
You might consider have a function that test for the empty rs and return an
integer (instead of an boolean), if its empty  0 and if not the number of
records.
Best regards.
:-) L.P.P.



Quote:
> Hi LPP,

> as I said: The using it's not effective in a loop. Because the program has
> to check every circle the status of the EOF-Flag - that means a request to
> the database.
> If you have only a few record entries it makes no much difference but ...

> Try this and measure the difference:

> Dim lCount As Long
> Dim i As Long

> With rec
>     .MoveLast
>     lCount = .RecordCount
>     .MoveFirst
>     For i = 1 To lCount
>         lstcustomer.AddItem , , !koc
>         .MoveNext
>     Next i
> End With

> cu
> Mayk



Thu, 27 Dec 2001 03:00:00 GMT
 Error 3021 ( recordset returns either EOF or BOF is TRUE)
Hi Kawi,

Public Function isEmpty() As Boolean

    Dim rec     As adodb.Recordset
    Dim query   As String
    Dim lCount  As Long
    Dim i       As Long

    Set rec = New adodb.Recordset
    query = "SELECT * FROM customer WHERE koc = '" & txtcode.Text & "'"
    Set rec = con.execute(query)

    With rec
        If (.EOF And .BOF) = False Then
            .MoveLast
            lCount = .RecordCount
            .MoveFirst
            For i = 1 To lCount
                lstcustomer.AddItem , , !koc
                .MoveNext
            Next i
            isEmpty = False
        Else
            isEmpty = True
        End If
        .Close
    End With
    Set rec = Nothing

End Function

--
???
Mayk



Sun, 30 Dec 2001 03:00:00 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Error 3021 ( recordset returns either EOF or BOF is TRUE)

2. ADO Error 3021 - Either BOF or EOF is True problem using VB

3. 3021 Either BOF or EOF is true?

4. Error 3021 "Either EOF or BOF, record may be deleted

5. Error 3021: BOF or EOF or record deleted in MoveComplete

6. Error 3021 BOF and EOF

7. Either EOF or BOF is TRUE...

8. Either EOF or BOF is true....

9. Either EOF or BOF is true....

10. Error: BOF or EOF is TRUE, HELP!

11. Either BOF or EOF ? with MDAC 2.6

12. Either EOF or BOF...


 
Powered by phpBB® Forum Software