iOS Question For each item in row?

Ross Woodward

Member
Licensed User
Longtime User
Hi there,

hope you can help me. I'm new to B4i and I'm trying to get For Each working.

I'm using build in SQLite and I have some rows in table with data in.

My plan is to run command that will get names from the row, and for each row it will programmatically create label.

B4X:
SQLResultSet = SQL.ExecQuery("SELECT name FROM category")

That should get the names from the category column.
Then I have learned that I need to use
B4X:
SQLResultSet.NextRow
to display the item.

I'm trying to figure out, how can I use "For Each" I saw the
B4X:
 For i = 0 TO 10
, but in here I have to specify how many times it will run. I would prefer that the code will run for each row in DB that is used, like in VB code.

B4X:
For each i in SQLResultSet
       label.text = SQLResultSet.GetString("category")
Next

This won't work.. What do I have to use instead of this?
 

Ross Woodward

Member
Licensed User
Longtime User
ignore my post, I just found it;

B4X:
Do While SQLResultSet.NextRow
     'my code
Loop

Does what I need it. Was expecting For Each instead of Do While... Anyway..
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…