B4J Question Current position is after the last row

Pablocao

Member
Hello again.
Im trying to go through a loop in a query to check the last that fulfill a condition, but i get this error continuosly. Dunno if my concept of the function .NextRow is wrong, but the problem is in the "position" of the cursor.
Im using mariadb as you can see in the image.
Error:


Code:
B4X:
Sub DB_getLastRow(TableName As String, field As String, order As String) As List
    Dim Cursor As ResultSet
    Dim result As List
  
    result.Initialize
    Cursor = SQL_BBDD.ExecQuery2($"SELECT ${field} FROM ${TableName} ORDER BY ${order} DESC LIMIT 1"$, Null)
    Do While Cursor.NextRow
        If Cursor.GetString(field).Contains("000001") = false Then
           Exit
        End If
    Loop
    result.Add(Cursor.GetString(field))
    Cursor.Close
  
    Return result
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…