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

Post Reply
User avatar
Willi Quintana
Posts: 1023
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

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

Post 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

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)

 
User avatar
anserkk
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

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

Post by anserkk »

What about calling oData:MoveFirst() before starting the Do while Loop ?
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

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

Post 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

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
User avatar
Willi Quintana
Posts: 1023
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

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

Post by Willi Quintana »

Thanks Mr Rao....
Post Reply