【发布时间】:2012-06-08 22:54:29
【问题描述】:
从另一个表单对数据库进行更改后如何刷新datagridview, 关闭子窗体后,我尝试使用单击事件刷新 datagridview,但它不起作用,我必须使用数据集吗?
//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();
}
帮帮我,请提前谢谢
【问题讨论】:
标签: c# datagridview dataset dataadapter