大致是这些代码:
可是用了update方法,当你在datagrid执行删除添加操作时候,怎么数据库不执行相应的操作啊?高手帮帮忙
public OleDbConnection olecnt=null;
public OleDbCommand olecmd=null;
public OleDbDataAdapter oleadp=null;
public OleDbCommandBuilder olecb=null;
public DataSet ds=new DataSet();
。。。。。。。。
。。。。。。。。
private void button1_Click(object sender, System.EventArgs e)
{
olecnt=new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source="+Application.StartupPath+"\\student.mdb");
olecmd=new OleDbCommand("select * from student",olecnt);
olecnt.Open();
oleadp=new OleDbDataAdapter(olecmd);
oleadp.SelectCommand=olecmd;
OleDbCommandBuilder olecb=new OleDbCommandBuilder(oleadp);
ds.Clear();
oleadp.Fill(ds,"student");
oleadp.Update(ds.Tables["student"]);
olecnt.Close();
}