OK, here you are:
Put the following code into the OK button:
Var f As New FolderItem
Var db As New SQLiteDatabase
// Get the db located in the Desktop, named Products.sqlite
f = SpecialFolder.Desktop.Child("Products.sqlite")
// Assign the file to the SQLiteDatabase Class
db.DatabaseFile = f
Try
// Connect to it
db.Connect
System.DebugLog "DB connected !"
Catch e As DatabaseException
MessageBox(e.Message)
End Try
// Now, the read from the db / display in the ListBox (LB) process
Var rowsFound As RowSet
Var Loop_Idx As Integer
Try
rowsFound = db.SelectSQL("SELECT * FROM List_Data") // Use your db TABLE name
For Each row As DatabaseRow In rowsFound
// Set the ListBox number of Columns
If LB.ColumnCount <> Row.ColumnCount Then
LB.ColumnCount = Row.ColumnCount - 1 // Skip the Row ID
End If
LB.AddRow ""
For Loop_Idx = 0 To row.ColumnCount - 1
LB.CellTextAt(LB.LastAddedRowIndex, Loop_Idx) = row.ColumnAt(Loop_Idx).StringValue
Next
Next
rowsFound.Close
Catch error As DatabaseException
MessageBox("Error: " + error.Message)
End Try
I changed the way the number of columns (ListBox) is set to avoid showing the RowID (provided it is in the last Column); and it is now set automatically (depends on the number of columns in the database)…
Result with my db:
The main window