private OleDbDataAdapter ad;
private DataSet ds = new DataSet();
private OleDbCommandBuilder mybd;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string strcon = "provider=microsoft.jet.oledb.4.0;data source=db1.mdb";
OleDbConnection connection= new OleDbConnection(strcon);
string st = "select * from s";
connection.Open();
OleDbDataAdapter ad = new OleDbDataAdapter(st,connection);
OleDbCommandBuilder odb = new OleDbCommandBuilder(ad);
DataSet ds = new DataSet();
ad.Fill(ds,"s");
System.Windows.Forms.BindingManagerBase mybin;
mybin=this.BindingContext[ds,"s"];
OleDbCommand mycommand = new OleDbCommand("insert into s values ('"+textBox1.Text+"','"+textBox2.Text+"')",connection);
mycommand.ExecuteNonQuery();
ds.Tables["s"].Rows[mybin.Position].BeginEdit();
ds.Tables["s"].Rows[mybin.Position].EndEdit();
ds.Tables["s"].AcceptChanges();
connection.Close();
dataGrid1.SetDataBinding(ds, "s");