Hello,
I have an sql query that returns 4 columns.
How can i add the data to a list so that each row in the list is a record from the result of the query but the list will also reflect the 4 columns?
Type sectionRec (id As Int, title As String, row As Int)
B4X:
Then you transfer the data from each SQL record to a new object like this ...
B4X:
Public Sub getSections(pageId As Int) As List
Dim cur As ResultSet
Dim result As List
result.Initialize
cur = dB.ExecQuery(SQL_SELECT_SECTIONS & pageId & " ORDER BY Row")
Do While cur.NextRow
Dim s As sectionRec
s.Initialize
s.Id = cur.GetInt2(0)
s.title = cur.GetString2(1)
s.row = cur.GetInt2(2)
result.Add(s)
Loop
Return result
End Sub
DBUtils2.ExecuteMemoryTable (SQL As SQL, Query As String, StringArgs As String, Limit As Int)
Executes the query and returns the result as a list of arrays.
Each item in the list is a strings array.
StringArgs - Values to replace question marks in the query. Pass Null if not needed.
Limit - Limits the results. Pass 0 for all results.
Returns : List
See: DBUtils2.ExecuteMap(SQL As SQL, Query As String, StringArgs As String)
'Executes the query and returns a Map with the column names as the keys
'and the first record values As the entries values.
'The keys are lower cased.
'Returns an uninitialized map if there are no results.
Hello,
I have an sql query that returns 4 columns.
How can i add the data to a list so that each row in the list is a record from the result of the query but the list will also reflect the 4 columns?