【请教】Access数据库insert一条数据之后,datagridview不能即时更新的问题
datagridview1在form1窗体中,form2窗体有对Access数据库进行改写的button1,我能够做到点击button1之后对数据库插入一条新的数据,可是form1中的datagridview1控件却没有即时对我插入的数据进行更新。我用的代码如下:程序代码:
OleDbConnection officer_connection = new OleDbConnection(); officer_connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=officer.mdb"; Form1 myForm1 = new Form1();//实例化form1窗体 officer_connection.Open(); OleDbCommand upd_command = new OleDbCommand("select * from 员工信息",officer_connection); OleDbDataAdapter officer_adapeter = new OleDbDataAdapter(); officer_adapeter.SelectCommand = upd_command; DataSet mydataset = new DataSet(); officer_adapeter.Fill(mydataset,"员工信息"); myForm1.dataGridView1.DataSource = mydataset.Tables["员工信息"] ; officer_connection.Close(); upd_command.Dispose();
还请高手指点如何修改或者如何做?