[Gambas-user] database eof and bof

Neil Fallon nfallo at ...734...
Sun Mar 6 07:31:40 CET 2005


On Sun, 2005-03-06 at 01:20 -0500, Rob wrote:
> On Sunday 06 March 2005 00:58, Neil Fallon wrote:
> > Hi,
> >
> > I have searched the archive and checked the documentation but can't
> > seem to find an answer.  Does Gambas support EOF and BOF when
> > working with databases?  In VB you would write something like
> >
> > If rsResult.EOF = True Then
> > 	do something
> > Else
> > 	do something else
> > End If
> >
> >
> > If it doesn't support EOF and BOF what is the suggested way of
> > trapping the beginning and end of a database if the items aren't
> > loaded into a list or combobox?
> 
> EOF and BOF are merged into one property, "Available".  r.Available in 
> Gambas is like "not r.EOF" in VB.
> 
> (r as Result, as I usually do)
> 
> r.MoveNext
> If r.Available Then
> 	' gimme some data
> Else
> 	' close the DB
> End If
> 
> I agree that this should be documented better or mentioned in the 
> DifferencesFromVB page.  Here is the page on Available:
> 
> http://www.binara.com/gambas-wiki/bin/view/Gambas/GbDbResult
> 
> Note that when you're iterating through a whole recordset, rather than 
> doing the Do...Loop thing, in Gambas it's easier to use For 
> Each...Next thing.
> 
> FOR EACH r
>   ' gimme some data
> NEXT
> 
> No BOF, EOF or Available required.  Of course if you're moving forward 
> and backward at the whims of a user, you're stuck checking 
> r.Available.
> 
> Rov
> 
Hi Roy,

I am at the whims of the users moving forward and backward.  The easier
way for me may be to just check the first and last records in the
database.  My key field is an auto increment number.  I can just check
if the value is 1 for the first record or what ever the number is for
the last record value in the database.

Neil






More information about the User mailing list