[Gambas-user] How to enumerate through SQL Result (was Re: Gambas-user Digest, Vol 132, Issue 29)

Unaise EK unaiseek at ...626...
Thu May 25 17:43:32 CEST 2017


Sir
My problem solved
Public Procedure AddList()
  Dim ListQurey As String
  Dim Lresult As Result

  ListQurey = "SELECT name FROM name_tbl"
  Lresult = MODMain.MyConn.Exec(ListQurey)
  'If Lresult.Count > 0 Then
  '*  Do While Not Eof(Lresult)*
  while Lresult.available
      ListBox1.Add(Lresult!"name")
      Lresult.MoveNext
  wend
  'Endif

On 25 May 2017 9:06 p.m., "T Lee Davidson" <t.lee.davidson at ...626...> wrote:

> On 05/25/2017 05:24 AM, Unaise EK wrote:
> > this is my code for displaying data in listbox, but it did not working,
> pls
> > help
> >
> > Public Procedure AddList()
> >    Dim ListQurey As String
> >    Dim Lresult As Result
> >
> >    ListQurey = "SELECT name FROM name_tbl"
> >    Lresult = MODMain.MyConn.Exec(ListQurey)
> >    If Lresult.Count > 0 Then
> >    *  Do While Not Eof(Lresult)*
> >        ListBox1.Add(Lresult!"name")
> >        Lresult.MoveNext
> >      Loop
> >    Endif
> >
> > End
>
> I don't know why you are trying to use Eof() on a SQL Result. Eof is for a
> Stream.
>
> See:
> http://gambaswiki.org/wiki/comp/gb.db/result
>
> "This class is enumerable with the FOR EACH keyword."
>
> And, I believe 'ListBox1.Add(Lresult!"name")' should be
> 'ListBox1.Add(Lresult!name)' or 'ListBox1.Add(Lresult["name"])'.
>
>
> Also, please try to compose meaningful subject lines by creating a _new_
> message instead of simply replying to a message that is
> not related to your issue. That helps those who view list messages in
> threaded mode. TIA.
>
> --
> Lee
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list