Hi,
this is an example to list the tables stored in a SQLite database in a Listview:
Get the list of tables for a database
Sub Database_GetTables As List
Dim result As List
result.Initialize
Dim cursor As ResultSet
Dim cmd As String = "SELECT * FROM sqlite_master WHERE TYPE=""table"" ORDER BY name;"
Try
cursor = gSQL.ExecQuery (cmd)
Do While cursor.NextRow
result.Add(cursor.GetString("name"))
Loop
Catch
Log("ERROR: " & LastException.Message)
End Try
Return result
End Sub
Add the tables to the Listview (declared as Private lvwDBTables As ListView)
lvwDBTables.Items.Clear
lvwDBTables.Items.AddAll(Database_GetTables)
The listview_selection change event can be used to retrieve the table content using SQLQuery.
Hints:
When using SQLite, do not forget to add the SQLite external library, stored in the B4J addittional library folder, as an external jar in the Project Properties
#AdditionalJar: sqlite-jdbc-3.7.2
and to add the jSQL library and a global SQL object (like Private gSQL As SQL)