Page 1 of 1

Mr. Rao EOF() BOF() not working wirh RecSet

PostPosted: Thu Feb 01, 2024 11:42 am
by Willi Quintana
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: Select all  Expand view

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)

 

Re: Mr. Rao EOF() BOF() not working wirh RecSet

PostPosted: Fri Feb 02, 2024 4:24 am
by anserkk
What about calling oData:MoveFirst() before starting the Do while Loop ?

Re: Mr. Rao EOF() BOF() not working wirh RecSet

PostPosted: Fri Feb 02, 2024 8:08 am
by nageswaragunupudi
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: Select all  Expand view
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.

Re: Mr. Rao EOF() BOF() not working wirh RecSet

PostPosted: Fri Feb 02, 2024 4:13 pm
by Willi Quintana
Thanks Mr Rao....