We help IT Professionals succeed at work.

Populate combo box in UWP from SQLite DB

High Priority
Last Modified: 2019-09-03
I am trying to fill a combo Box with a list of items from a SQLite DB.
have been using/following with this https://docs.microsoft.com/en-us/windows/uwp/data-access/sqlite-databases#choose-an-abstraction-layer

SO in my
DataAcsess.cs Class i have
 public static List<String> ProductList()

            List<String> entries = new List<string>();

            using (SqliteConnection db =
                new SqliteConnection("Filename=DataStorage.db"))

                SqliteCommand selectCommand = new SqliteCommand
                    ("SELECT DOTProductname from QPL", db);

                SqliteDataReader reader = selectCommand.ExecuteReader();

                while (reader.Read())

            return entries;

Open in new window

(which I am not sure what it is doing)

then i have a

I have my XAML:
                    <ComboBox  x:Name="PName" HorizontalContentAlignment="Center" MinWidth="140" ItemsSource="{Binding}">


Open in new window

(not sure how i get the item source to work)

and finally my

XAML.CS code:
  private void ProductList(object sender, RoutedEventArgs e)
          ComboBox.ItemsSource = DataAccess.ProductList();

Open in new window

Which is throwing some errors because i am not understanding what is required.

How is the standard method to get the query convert it to a item
and then put a foreach item loop to add to my combo box or similar?
appreciate your help in advance.
Watch Question

Hi David
Hope you have followed all steps in your reference:


I would suggest to replicate all steps as it is first (with only two changes, database connection string and sql command).
Then check if you are getting result.
If you not getting then something is missing in configuration or with db connection.
If you are getting result then modify that code according to your need.

Hope this helps you.