title: C# SQL Columns into ComboBox
body: <p>My SQL query isn't dropping anything into the combobox. The connection seems to be made but the while loop doesn't seem to work. Can anybody tell me what it wrong?</p>
  
  <pre><code>string sqltable = ("dbo.SLTDS_C"+id+"_table");  
  
  SqlConnection con = new SqlConnection("Data Source=" + server   + ";Initial Catalog=" + database + ";Integrated Security=" + security);  
  con.Open();  
  </code></pre>
  
  <p>string sqldatapull = ("select name from syscolumns where id = object_id('" + sqltable + "') order by name asc");<br>
      SqlCommand cmd = new SqlCommand(sqldatapull, con);<br>
      cmd.CommandType = CommandType.Text;<br>
      SqlDataReader dr = cmd.ExecuteReader();  </p>
  
  <pre><code>while (dr.Read())  
  {  
      sqldatapull = dr[0].ToString();  
      comboBox1.Items.Add(sqldatapull);  
  }  
  
  dr.Close();  
  con.Close();  
  </code></pre>
  
  <hr>
  
  <p>Correction code:<br>
  string sqldatapull = ("select name from syscolumns where id = object_id('" + sqltable + "') order by name asc");</p>