title: SQL Server: Datagridview display column value from table
body: <p>I want to display in datagridview a specified column value. Example: from table <code>user_account</code> I want to display and search by textbox data from column <code>account</code> in datagridview</p>
  
  <p>Here is the code so far:</p>
  
  <pre><code>private void button3_Click(object sender, EventArgs e)
  {
          string connectionString = @"Data Source=" + textBox4.Text + ";" + "Initial Catalog=" + textBox1.Text + ";" + "User ID=" + textBox2.Text + ";" + "Password=" + textBox3.Text;
          string sql = "SELECT * FROM user_account";
          SqlConnection connection = new SqlConnection(connectionString) ;
          SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
          DataSet ds = new DataSet();
          connection.Open();
          dataadapter.Fill(ds, "account");
          connection.Close();
          dataGridView1.DataSource = ds;
          dataGridView1.DataMember = "account";
      }
  </code></pre>