Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh datagridview win forms after updating the database from a child form

how to refresh datagridview after making changes on the database from another form, after closing child form i tried to refresh the datagridview with click event but it's not working, do i have to use dataset ?

            //create an OleDbDataAdapter to execute the query
            dAdapter = new OleDbDataAdapter(gQuery, connString);

            //create a command builder
            cBuilder = new OleDbCommandBuilder(dAdapter);

            //create a DataTable to hold the query results
            dTable = new DataTable();

            //fill the DataTable
            dAdapter.Fill(dTable);


            //BindingSource to sync DataTable and DataGridView
            bSource = new BindingSource();

            //set the BindingSource DataSource
            bSource.DataSource = dTable;


            //set the DataGridView DataSource
            dataGridView1.DataSource = bSource;

    private void button_Refresh_Click(object sender, EventArgs e)
    {

        dataGridView1.DataSource = bSource;
        dataGridView1.Refresh();


    }

Help me, please thanks in advance

like image 682
sevoug Avatar asked Jun 04 '12 21:06

sevoug


1 Answers

Add

dataGridView1.Update();

It will solve your problem.

like image 98
Nitin Gupta Avatar answered Sep 18 '22 15:09

Nitin Gupta