Hi there i am trying to load MySql table data into a datagridview in my win forms application on button click, and cant seem to get it to work. I think im missing the binding source but im very confused.
Some help would be appreciated.
private void button3_Click(object sender, EventArgs e)
{
string connStr = "Data Source=localhost;port=3306;Initial Catalog=bitdb;User Id=root;Password='';";
string query = "Select * from Client";
using (MySqlConnection conn = new MySqlConnection(connStr))
{
using (MySqlDataAdapter adapter = new MySqlDataAdapter(query, conn))
{
DataSet ds = new DataSet();
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
}
}