I am trying to read data from a sqlite table and place each record into a variable:
My SQL statement is:
My Code is:
I get the following error:
My SQL statement is:
B4X:
Cursor1 = SQL0.ExecQuery("SELECT DISTINCT StoreGroup FROM tableSP2")
My Code is:
B4X:
Sub GetStoreGroups
Dim StoreGroup1 As String
Dim StoreGroup2 As String
Dim StoreGroup3 As String
Dim StoreGroup4 As String
Dim StoreGroup5 As String
Dim StoreGroupCount As Int
Dim Cursor1 As Cursor
Cursor1 = SQL0.ExecQuery("SELECT DISTINCT StoreGroup FROM tableSP2")
StoreGroupCount = Cursor1.RowCount
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
StoreGroup1 = (Cursor1.GetString2(0))
StoreGroup2 = (Cursor1.GetString2(1))
StoreGroup3 = (Cursor1.GetString2(2))
StoreGroup4 = (Cursor1.GetString2(3))
StoreGroup5 = (Cursor1.GetString2(4))
Next
Cursor1.Close
End Sub
I get the following error:
B4X:
java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.