title: Populate a combobox with value taken from SQL Server CE table
body: <p><img src="https://i.stack.imgur.com/9r3rp.png" alt="enter image description here"></p>
  
  <p>I've been working on this basic form for a while now and have hit my latest stumbling block.
  What works so far is the following: You input an ID into the text box, Click the Load button, select your <code>.jpg</code> this then displays the image in the picture box at the top (in this example its a camcorder).</p>
  
  <p>Now for the problem, when you click the <code>Save</code> button it makes a call to a method named <code>updatedata();</code></p>
  
  <p>This I believe is writing the image and ID to my SQL Server CE database (I have done it a few times in the bin\debug folder and the db has grown in size.) The method also makes a call to another method named <code>Connection();</code></p>
  
  <p>Now, the idea of the connection method is to populate the ID combobox based on any items that have been saved to the db, so basically every time I add a new image, the picklist should refresh and be available for selection, currently it is not doing anything because the code I used was initially written for a proper instance of SQL Server, not CE. I have attempted to refactor some of it however I am now getting the below error.</p>
  
  <p><img src="https://i.stack.imgur.com/S0G17.png" alt="enter image description here"></p>
  
  <p>Here is the code for my connection method:</p>
  
  <pre><code>private void Connection() 
  {   
            //connect to the database and table
            //selecting all the columns
            //adding the name column alone to the combobox 
  
           try 
           {
               string connstr = @"Data Source=.\TestImage.sdf;Persist Security Info=False;"; 
  
               SqlCeConnection conn = new SqlCeConnection(connstr);  
               conn.Open();
               empadap1 = new SqlDataAdapter();   
               empadap1.SelectCommand = new SqlCommand("SELECT * FROM test_table"
                   , conn); 
               dset = new DataSet("dset");
               empadap1.Fill(dset);   
               DataTable dtable;     
               dtable = dset.Tables[0];
               comboBox1.Items.Clear(); 
               foreach (DataRow drow in dtable.Rows)
               { 
                comboBox1.Items.Add(drow[0].ToString()); 
                comboBox1.SelectedIndex = 0; 
               } 
           }
           catch (Exception ex)
           {
            MessageBox.Show(ex.Message);    
           }   
  }
  </code></pre>
  
  <p><strong>Question</strong><br>
  Can anyone ammend my Connection() method code to do what I want (i.e. update the combobox with all saved ID's found within the SQL Server CE database) or suggest some new code.</p>
  
  <p><strong>Side Note</strong><br>
  Once my combobox is populating I will attempt to code the 'Retrieve' button based on the selected ID which will then display the selected image in a second picture box below the first one however I think it is best if I keep that a separate issue!</p>