iOS Question B4I Cursor

Sergio Haurat

Active Member
Licensed User
Longtime User
This function on Android works without problems, on iOS it shows an error. It just makes a query to a table and fills a map with the result.
I tried to simulate with DBUtils but it only returns the first record

[CODE lang="b4x" title="Code"]Public Sub get_federations_map(strOrderField As String) As Map
Dim mapTemp As Map
mapTemp.Initialize
Dim sqlSelect As SQL
Dim sqlCursor As Cursor
sqlSelect.Initialize(xui.DefaultFolder, "strings.db", False)
sqlCursor = sqlSelect.ExecQuery("SELECT _id, " & strOrderField & " FROM cmn_lst_federaciones WHERE _id >= 4 ORDER BY " & strOrderField)
For iCnt = 0 To sqlCursor.RowCount - 1
sqlCursor.Position = iCnt
mapTemp.Put(sqlCursor.GetInt("_id"), sqlCursor.GetString(strOrderField))
Next
sqlSelect.Close
Return mapTemp
End Sub[/CODE]

B4A IDE
1718925705429.png


B4I IDE
1718925763461.png
 
Solution
B4X:
Dim MainRS As ResultSet = B4XPages.MainPage.SQL.ExecQuery2(....)
Do While MainRS.NextRow

    Dim ITEM_ID As String = MainRS.GetString("ITEM_ID")
    NExt
    MainRS.close
B4X:
Dim MainRS As ResultSet = B4XPages.MainPage.SQL.ExecQuery2(....)
Do While MainRS.NextRow

    Dim ITEM_ID As String = MainRS.GetString("ITEM_ID")
    NExt
    MainRS.close
 
Upvote 0
Solution
This function on Android works without problems, on iOS it shows an error. It just makes a query to a table and fills a map with the result.
I tried to simulate with DBUtils but it only returns the first record

[CODE lang="b4x" title="Code"]Public Sub get_federations_map(strOrderField As String) As Map
Dim mapTemp As Map
mapTemp.Initialize
Dim sqlSelect As SQL
Dim sqlCursor As Cursor
sqlSelect.Initialize(xui.DefaultFolder, "strings.db", False)
sqlCursor = sqlSelect.ExecQuery("SELECT _id, " & strOrderField & " FROM cmn_lst_federaciones WHERE _id >= 4 ORDER BY " & strOrderField)
For iCnt = 0 To sqlCursor.RowCount - 1
sqlCursor.Position = iCnt
mapTemp.Put(sqlCursor.GetInt("_id"), sqlCursor.GetString(strOrderField))
Next
sqlSelect.Close
Return mapTemp
End Sub[/CODE]

B4A IDE
View attachment 154769

B4I IDE
View attachment 154770

As @jahswant said in the answer but not stressed out, "ResultSet", can be used in all B4X IDEs except obviously B4R.
 
Upvote 0
Back
Top