B4J Question How to retrieve value from spesific field?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have codes like these
B4X:
Sub Test
   Private RS As ResultSet
   Private Qry as SQL
   RS = Qry.ExecQuery("select * from table where id = 10")
   For i = 0 To RS.ColumnCount - 1
      Log(RS.GetString(RS.GetColumnName(i)))
   Next
End Sub

Raised an error
(SQLException) java.sql.SQLException: The result set is not in a row, use next

How to fix that error?

NB : Can't use do while RS.NextRow caused number of columns are variable.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Make sure to close the result set when done.
Can't use do while RS.NextRow caused number of columns are variable.
No relation between the two. You must use RS.NextRow:
B4X:
Dim rs As ResultSet = QRY.ExecQuery2("select * from table where id = ?", Array(10))
Do While rs.NextRow
  For i = 0 To RS.ColumnCount - 1
      Log(RS.GetString(RS.GetColumnName(i)))
   Next
Loop
rs.Close
 
Upvote 0
Top