Hi,
I'm playing with SQL by create a simple app with 2 pages. However, it only works first time, the second time run there's error "SQL ExecQuery error: out of memory" even the database is very small.
Here the code:
Or you can find the attachment. Thanks.
I'm playing with SQL by create a simple app with 2 pages. However, it only works first time, the second time run there's error "SQL ExecQuery error: out of memory" even the database is very small.
Here the code:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1, Page2 As Page
Public SQL1 As SQL
Public SQLDataBasePath = File.DirDocuments As String
Public SQLDateBaseName = "persons.db" As String
Public SelectedName As String
Private btJohn, btGeorge As Button
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
Page1.RootPanel.LoadLayout("page1")
NavControl.ShowPage(Page1)
Page2.Initialize("Page2")
Page2.Title = "Page 2"
Page2.RootPanel.LoadLayout("page2")
If File.Exists(SQLDataBasePath, SQLDateBaseName) = False Then
File.Copy(File.DirAssets, SQLDateBaseName, SQLDataBasePath, SQLDateBaseName)
SQL1.Initialize(SQLDataBasePath, SQLDateBaseName, False)
Else
SQL1.Initialize(SQLDataBasePath, SQLDateBaseName, False)
End If
End Sub
Sub btJohn_Click
SelectedName = "John"
NavControl.ShowPage(Page2)
End Sub
Sub btGeorge_Click
SelectedName = "George"
NavControl.ShowPage(Page2)
End Sub
Private Sub page2_Appear
Dim query As String
query = "select ID from persons where FirstName = '"&SelectedName&"'"
Dim rs As ResultSet
rs = SQL1.ExecQuery(query)
Do While rs.NextRow
Log(rs.GetString("ID"))
Loop
SQL1.Close
End Sub
Or you can find the attachment. Thanks.