iOS Question Counting Rows with resultset

Discussion in 'iOS Questions' started by tufanv, Jun 11, 2015.

  1. tufanv

    tufanv Expert Licensed User

    Hello,

    I know we must use nextrow method with b4i but i cant count the number of rows with it . Is there an easy vay to count rws of a result set ?

    TY
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can always add a count(*) column to the query.

    "Select Col1, Col2, Count(*) As MyCount FROM ..."
     
    jinyistudio likes this.
  3. tufanv

    tufanv Expert Licensed User

    I am using
    for i = 0 to cursor4.rowcount-1 and i cant figure out how to use count in query with this purpose . Can you show a little example for my for next ( or can i use do while resultset.nextrow loop instead of for i=0 to rowcount-1 ? )
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You don't need the count at all.
    The correct way is:
    Code:
    Dim rs As ResultSet = SQL.ExecuteQuery(...)
    Do While rs.NextRow
     
    Log(rs.GetString("Col1"))
    Loop
    rs.Close
     
  5. billyrudi

    billyrudi Active Member Licensed User

    There is the way to make a previous row metod?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    No. However you can use DBUtils.ExecuteMemoryTable and then have access to all the items.
     
  7. billyrudi

    billyrudi Active Member Licensed User

    Great. Tanks another time.
     
  8. tufanv

    tufanv Expert Licensed User

    Erel Do I have to close the resultset everytime. For example if i use rs1 for 2 different queries do i have to close and use again unlike the cursor ?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    You always need to close the ResultSet when you are done with it. The same is true with Android cursors.

    The variable that holds the ResultSet is not important. If you are using the same variable then you need to close it before you assign it again.
     
Loading...