title: C# Return List of Databases in Combobox
body: <p>I have two comboboxes, <code>comboBoxSelectServer</code> and <code>comboBoxSelectDatabase</code>.</p>
  
  <p>Based on the value selected in <code>comboBoxSelectServer</code> when the user clicks on <code>comboBoxSelectDatabase</code> they will get the various databases from that server. </p>
  
  <p>However, when running the application I'm not getting any databases returned in <code>comboBoxSelectDatabase</code>. </p>
  
  <p>I think its due to the below section of my code, as on debugging its not pulling back anything.</p>
  
  <pre><code>comboBoxSelectDatabase.Items.Add(command);
  </code></pre>
  
  <p>I've included my code below;</p>
  
  <pre><code>if (comboBoxSelectServer.SelectedIndex == 0)
  {
      string commandTextSERV1 = "SELECT name FROM master.sys.databases " +
                                "where name LIKE 'Client_%'";
  
      string connectionString = Properties.Settings.Default.connectionStringSERV1;
  
      using (SqlConnection con = new SqlConnection(connectionString))
      {
          SqlCommand command = new SqlCommand(commandTextSERV1, con);
  
          try
          {
              con.Open();
              command.ExecuteNonQuery();
              SqlDataReader reader = command.ExecuteReader();
  
              if (reader.Read())
              {
                  comboBoxSelectDatabase.Items.Add(command);
              }
              else
              {
                  MessageBox.Show("Error");
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
          finally
          {
              con.Close();
          }
      }
  }
  </code></pre>