title: Display tables from SQL in DataGridView
body: <p>I created a DataBase named <em>charityah</em> containing 5 tables. Their names are listed in a combobox.</p>
  
  <p>When I choose one of them I want to display their content in a DataGridView.</p>
  
  <p>What I tried is: first I linked the DataGridView to this database and tried this code that I found:</p>
  
  <pre><code>SqlConnection connection = new SqlConnection();
  
  private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
      string s = comboBox1.Text;
  
      connection.ConnectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Downloads\charityah.mdf;Integrated Security=True";
  
      using (connection)
      {
          connection.Open();
          SqlDataAdapter adapter = new SqlDataAdapter("select * from "+s, connection);
          DataSet ds = new DataSet();
          adapter.Fill(ds, s);
          dataGridView1.DataSource = ds.Tables[0];
          dataGridView1.Refresh();   
      }
  }
  </code></pre>
  
  <p>This method doesn't give me any errors and it finds the tables, but nothing is seen in the DataGridView. </p>