tufanv Expert Licensed User Longtime User Jun 11, 2015 #1 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
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
Erel B4X founder Staff member Licensed User Longtime User Jun 11, 2015 #2 You can always add a count(*) column to the query. "Select Col1, Col2, Count(*) As MyCount FROM ..." Upvote 0
tufanv Expert Licensed User Longtime User Jun 11, 2015 #3 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 ? ) Upvote 0
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 ? )
Erel B4X founder Staff member Licensed User Longtime User Jun 11, 2015 #4 You don't need the count at all. The correct way is: B4X: Dim rs As ResultSet = SQL.ExecuteQuery(...) Do While rs.NextRow Log(rs.GetString("Col1")) Loop rs.Close Upvote 0
You don't need the count at all. The correct way is: B4X: Dim rs As ResultSet = SQL.ExecuteQuery(...) Do While rs.NextRow Log(rs.GetString("Col1")) Loop rs.Close
billyrudi Active Member Licensed User Longtime User Jun 11, 2015 #5 There is the way to make a previous row metod? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jun 11, 2015 #6 No. However you can use DBUtils.ExecuteMemoryTable and then have access to all the items. Upvote 0
billyrudi Active Member Licensed User Longtime User Jun 11, 2015 #7 Great. Tanks another time. Upvote 0
tufanv Expert Licensed User Longtime User Jun 11, 2015 #8 Erel said: You don't need the count at all. The correct way is: B4X: Dim rs As ResultSet = SQL.ExecuteQuery(...) Do While rs.NextRow Log(rs.GetString("Col1")) Loop rs.Close Click to expand... 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 ? Upvote 0
Erel said: You don't need the count at all. The correct way is: B4X: Dim rs As ResultSet = SQL.ExecuteQuery(...) Do While rs.NextRow Log(rs.GetString("Col1")) Loop rs.Close Click to expand... 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 ?
Erel B4X founder Staff member Licensed User Longtime User Jun 11, 2015 #9 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. Upvote 0
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.