[Gambas-user] How to enumerate through SQL Result (was Re: Gambas-user Digest, Vol 132, Issue 29)
T Lee Davidson
t.lee.davidson at ...626...
Thu May 25 17:35:19 CEST 2017
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
More information about the User
mailing list