locked
how do I bind data from sqlite to a combobox

    Question

  • Here is what I have so far:

           

    publicvoidPopPrograms()

           {

              

    vardbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "vsLocal");

              

    SQLiteAsyncConnectionconn;

            

    using(vardb = newSQLite.SQLiteConnection(dbPath))

               {

                    db.Query<

    PicPrograms>("select * from PicPrograms");

                   cbProgram.Items.Add(WHAT GOES HERE?);

                   db.RunInTransaction(() =>

                         {

                            

    //db.Insert(new PicPrograms() { ProgramID = "Tim", ProgramName = "Heuer" });


                            

    //db.Delete(new PicPrograms() { ProgramID = "Tim", ProgramName = "Heuer" });


                             

                       });

                    }

               }

           

    class PicPrograms


            {

               

    public string ProgramID { get; set; }

               

    public string ProgramName { get; set; }

            }



    • Edited by DeanO78O Thursday, September 4, 2014 6:04 PM
    Thursday, September 4, 2014 6:02 PM

Answers

  • The SQLiteConnection class is not part of any official library from Microsoft but you need to iterate through the results returned from the Query and add then add them to the Items collection of the ComboBox one by one:

    var results = db.Query<PicPrograms>("select * from PicPrograms");
    foreach(var pp in results)
    {
     cbProgram.Items.Add(pp.ProgramName); 
    }

    But please note that these forums are intended for Microsoft's products and technologies only and SQLite is not a Microsoft product.

    Please also remember to mark helpful posts as answer and/or helpful.

    • Marked as answer by DeanO78O Thursday, September 4, 2014 9:49 PM
    Thursday, September 4, 2014 8:36 PM