Guys,
I am reading lots of articles, but I still can't find the error in my code (below).
When running the form, the DGV shows the data, (3 rows, 3 cols).
-. I change the value in row 1, col 2 => nothing happens.
-. I change the value in row 1, col 2 and row 2, col 2 => Change in database only for row 1, col 2
-. I change the value in row 1, col 2 and row 2, col 2 and row 3, col 2 => Change in database only for row 1, col 2 and row 2, col 2
As you see, the last change never updates the database...
Evaluating the line
ds.HasChanges()
I see that for the first value, I always get "false", and then I get "true".
Thanks in advance for any help,
Aldo.
public frmGrid()
{
InitializeComponent();
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=D:\\Vi...Db1.mdb; Jet OLEDB:Database Password=x;");
System.Data.OleDb.OleDbCommand oleDbCommand = new System.Data.OleDb.OleDbCommand("SELECT * FROM Customers;");
oleDbCommand.Connection = conn;
//DataSet, OleDbDataAdapter, OleDbCommandBuilder were declared as static.
ds = new System.Data.DataSet();
daOleDb = new System.Data.OleDb.OleDbDataAdapter(oleDbCommand);
cbOleDb = new System.Data.OleDb.OleDbCommandBuilder(daOleDb);
daOleDb.Fill(ds, "t1");
dgv1.DataSource = ds;
dgv1.DataMember = "t1";
dgv1.CellEndEdit += new DataGridViewCellEventHandler(dgv1_CellEndEdit);
}
private void dgv1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
daOleDb.Update(ds, "t1");
}