FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Mr. Rao EOF() BOF() not working wirh RecSet
Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM
Mr. Rao EOF() BOF() not working wirh RecSet
Posted: Thu Feb 01, 2024 11:42 AM
Mr Rao
You can help me please , I use RecSet, but not work correctly, EOF() and BOF() not workink with RecSet, see you this example: I used MaeiaDb
Code (fw): Select all Collapse
Function ListaUser(oCn)
local lOK, cData, oData, aRet := {}

lOk := .t.

cData := "SELECT nick FROM usuarios ORDER BY nick"

TRY
  oData := oCn:RecSet( cData )
CATCH
  lOK := .f.
END

If lOk

  xbrowse(oData)           // <----------------------------ok..

  WHILE !oData:EOF()   // <--------- :EOF(), BOF()  With :RecSet not working, with RowSet  is Ok
    AADD(aRet, oData:nick )
    oData:Skip()
  ENDDO

EndIf

Return(aRet)
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Mr. Rao EOF() BOF() not working wirh RecSet
Posted: Fri Feb 02, 2024 04:24 AM

What about calling oData:MoveFirst() before starting the Do while Loop ?

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mr. Rao EOF() BOF() not working wirh RecSet
Posted: Fri Feb 02, 2024 08:08 AM
You are right.
With RecSet, eof() and bof() do not work.
We will try to provide this in future versions.
for now you can use this:
Code (fw): Select all Collapse
nRecs := oData:RecCount()
nSave := oData:RecNo()
do while oData:RecNo() <= nRecs
   // do whatever
   oData:Skip( 1 )
enddo
oData:GoTo( nSave )
Note:
We advise to use RecSet class if and only if the table is very large and there is no other go but to read and browse the entire table.
In all other cases use RowSet class with suitable WHERE clause.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM
Re: Mr. Rao EOF() BOF() not working wirh RecSet
Posted: Fri Feb 02, 2024 04:13 PM

Thanks Mr Rao....

Continue the discussion