Android Question How to use JdbcResultSet?

gacar

Active Member
This way only return last value in the table. How can i get only single value from a database table eg 5.row 3.column value or selected row 3.column value. Thanks

B4X:
     Dim rs As JdbcResultSet =  SQL.execquery("select * FROM Bolge")
     Do While rs.nextrow
        LabelIstanbul.Text = rs.getstring2(2)
     Loop
    rs.Close
 
Solution
B4X:
 Dim rs As JdbcResultSet =  SQL.execquery("select * FROM Bolge")
    Dim rowIndex As Int
     Do While rs.nextrow
        If rowIndex = 4 Then LabelIstanbul.Text = rs.getstring2(2)
        rowIndex = rowIndex + 1
     Loop
    rs.Close

Better solution is to add a WHERE clause and get the relevant value.

Mahares

Expert
Licensed User
Longtime User
Relying on the intrinsic order of the table is dangerous
To understand this better, doesn't the code in post #2 also rely on intrinsic order since no order by was provided and can cause the same issue as post #3.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
To understand this better, doesn't the code in post #2 also rely on intrinsic order since no order by was provided and can cause the same issue as post #3.
You are 100% correct. This is why I added: "Better solution is to add a WHERE clause and get the relevant value."
 
Upvote 0
Top