Click here to Skip to main content
15,500,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello. I am working on a project using SQlite for the first time. I have been able to load all tables to display in a combobox. Now i need to be able to display the details of any table you selected from the combobox to be displayed in a Listview.
I'll indeed be very grateful thank u.

What I have tried:

Dim conn As New SQLite.SQLiteConnection
Dim cmd As SQLiteCommand
Dim da As SQLite.SQLiteDataAdapter
Dim ds As SQLiteDataReader
Dim itemcoll(100) As String

Me.ListView1.View = View.Details
Me.ListView1.GridLines = True
conn = New SQLiteConnection(db)
Dim strQ As String = String.Empty
strQ = "SELECT * FROM " & ComboBox1.Text & """"
cmd = New SQLiteCommand(strQ, conn)
da = New SQLite.SQLiteDataAdapter(cmd)
Updated 9-Mar-21 8:29am

Share this answer
Try this:

Dim conn As New SQLiteConnection("Data Source=myDatabase.sql3;Version=3;")
        dim SQL as string = "SELECT * from lang;"
        Dim da As New SQLiteDataAdapter(Sql, conn)
        Dim ds As New DataSet
        da.Fill(ds, "lang")
        'Close the connection
        With ListView1
            .View = View.Details
            .HeaderStyle = ColumnHeaderStyle.Nonclickable ' set to whatever you need
            .Columns.Clear() ' make sure columnscollection is empty
            ' Add 3 columns

        End With
        For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
            ListView1.Items.Add(New ListViewItem({ds.Tables(0).Rows(i).Item(0).ToString(), ds.Tables(0).Rows(i).Item(1).ToString(), ds.Tables(0).Rows(i).Item(2).ToString()}))

This shows the whole process.
* Open the database
* Create the DataAdaptor(da) using the connection and SQL statement
* Create the dataset (ds)
* Fill the DataAdaptor with the contents of the lang table
* Add Columns to the Listview
* Add the contents of fields to the ListView
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900