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

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

Postby Willi Quintana » 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: 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)

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

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

Postby anserkk » Fri Feb 02, 2024 4:24 am

What about calling oData:MoveFirst() before starting the Do while Loop ?
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

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

Postby nageswaragunupudi » Fri Feb 02, 2024 8: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: 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

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

Postby Willi Quintana » Fri Feb 02, 2024 4:13 pm

Thanks Mr Rao....
User avatar
Willi Quintana
 
Posts: 1019
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests