Hello,
I am using a class module and want the class module to run a SQL query and load the text from the database in a string on the class module so I can get the names quicker and won't have to run multiple SQL query's later on in my app.
My Class module looks like the following:
Class Name: Test1
Then I am calling the class like:
but when I do that my app crashes.
I am doing this correctly?
I am using a class module and want the class module to run a SQL query and load the text from the database in a string on the class module so I can get the names quicker and won't have to run multiple SQL query's later on in my app.
My Class module looks like the following:
Class Name: Test1
B4X:
'Class module
Sub Class_Globals
Dim name(200) As String
Dim SQL1 As SQL
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
'Gets all names from the database and stores it in the string
Public Sub GetNames
For i = 1 To 200
name(i) = SQL1.ExecQuerySingleResult("SELECT name" & i & " FROM names WHERE id = 1")
Next
End Sub
'Displays the name of the requested item
Public Sub DisplayName(item)
Return name(item)
End Sub
Then I am calling the class like:
B4X:
CallSubDelayed("test1", "GetNames")
but when I do that my app crashes.
I am doing this correctly?