WebQuest Active Member Licensed User Longtime User Apr 6, 2021 #1 Hi guys I'm translating my app from B4a to B4i for IOS. In the documentation it is not specified whether a (cursor) should be used for queries as is the case on B4a. In fact, returning the code from B4a to B4i the Cursor method (dim C as Cursor) it is not possible to declare it. I guess he needs a library! I am using iSql but even with this library I cannot declare the cursor. Does anyone know how to do? In B4a I have this code: [CODE lang="b4x" title="B4a Code"] Dim c As Cursor c=s.ExecQuery("SELECT Name FROM Users") If c.RowCount>0 Then For i = 0 To c.RowCount - 1 c.Position = i Var1=c.GetString("Name") Next Log("Nome:"&Var1) c.Close End If[/CODE]
Hi guys I'm translating my app from B4a to B4i for IOS. In the documentation it is not specified whether a (cursor) should be used for queries as is the case on B4a. In fact, returning the code from B4a to B4i the Cursor method (dim C as Cursor) it is not possible to declare it. I guess he needs a library! I am using iSql but even with this library I cannot declare the cursor. Does anyone know how to do? In B4a I have this code: [CODE lang="b4x" title="B4a Code"] Dim c As Cursor c=s.ExecQuery("SELECT Name FROM Users") If c.RowCount>0 Then For i = 0 To c.RowCount - 1 c.Position = i Var1=c.GetString("Name") Next Log("Nome:"&Var1) c.Close End If[/CODE]
klaus Expert Licensed User Longtime User Apr 6, 2021 #2 Cursor does not exist in B4i nor in B4J. You must use ResultSet instead. B4X: Private ResultSet1 As ResultSet ResultSet1 = s.ExecQuery("SELECT Name FROM Users") Do While ResultSet1.NextRow Var1 = ResultSet1.GetString("Name") Loop You may change the code also in B4A, because the code above works also in B4A and then you are cross-platform. Upvote 0
Cursor does not exist in B4i nor in B4J. You must use ResultSet instead. B4X: Private ResultSet1 As ResultSet ResultSet1 = s.ExecQuery("SELECT Name FROM Users") Do While ResultSet1.NextRow Var1 = ResultSet1.GetString("Name") Loop You may change the code also in B4A, because the code above works also in B4A and then you are cross-platform.
WebQuest Active Member Licensed User Longtime User Apr 6, 2021 #3 Thank you for your quick answer. But yes 'Do while' what parameter do I insert? on b4a I got the total of the rows with C.RowCount! B4X: Do While ? 'code... loop Upvote 0
Thank you for your quick answer. But yes 'Do while' what parameter do I insert? on b4a I got the total of the rows with C.RowCount! B4X: Do While ? 'code... loop
Erel B4X founder Staff member Licensed User Longtime User Apr 6, 2021 #4 Code: Dim ResultSet1 As ResultSet = s.ExecQuery("SELECT Name FROM Users") Do While ResultSet1.NextRow Var1 = ResultSet1.GetString("Name") Loop This will also work in B4A and B4J. Avoid using Cursors. Upvote 0
Code: Dim ResultSet1 As ResultSet = s.ExecQuery("SELECT Name FROM Users") Do While ResultSet1.NextRow Var1 = ResultSet1.GetString("Name") Loop This will also work in B4A and B4J. Avoid using Cursors.