0
Reply

loading mysql to datagridview, datagridview became double

obulisundaram G

obulisundaram G

Oct 29 2013 5:18 AM
782
Hi,

   I am using mysql and datagridview for storing and retrieving purpose., I just done saving the data from datagridview to mysql. But while I'm loading mysql into again that same datagridview, the datagridview become twice.

I given the code below

private void btnload_Click(object sender, EventArgs e)
        {

            DataTable dt = new DataTable();
            string st = "select * from searchsong";
            MySqlDataAdapter ad = new MySqlDataAdapter(st, con);
            MySqlCommandBuilder cmd = new MySqlCommandBuilder(ad);
            ad.Fill(dt);
            BindingSource bg = new BindingSource();
            bg.DataSource = dt;
            dataGridView1.DataSource = bg;
           
        }

In this "con"- connection string and "searchsong" is table name.