B4J Code Snippet SQL rowcount

To get the number of rows returned by a query without having to traverse the whole resultset

Code:
Sub rowCount(rs As JavaObject) As Int
   rs.RunMethodJO("last",Null)
   Dim count As Int = rs.RunMethod("getRow",Null)
   rs.RunMethod("beforeFirst",Null) 
   Return count
End Sub

Use preferably before
Code:
   do while rs.NextRow

call with
Code:
   Log(rowCount(c1)) ' c1 is the resultset
 
Back
Top