Hello everyone,

as will be seen from the following massage I am new to C#.
I have dataGrid that reads data from mine database. Also, I can update database from dataGrid, but I want to update it in more ways. So, I have the following code just to see something, but to mine big surprise it does not give me the results that I expect:

dataSet1.Tables["Example"].Rows.ItemArray[j]=33 ;
MessageBox.Show(dataSet1.Tables["Example"].Rows .ItemArray[j].ToString());

MessageBox shows me the old value (the value is not changed). Why is that?

Thanks in advance.

Did you commit the changes done at the dataset?!

Did you commit the changes done at the dataset?!

Yes, I have tried it (it was also mine first guess), but with no results. I am doing something wrong, but don’t know what.

The row remains unchanged. For example the following code would give me message: “unchanged”

dataSet1.Tables["Example"].Rows.ItemArray[j]=33;
MessageBox.Show(dataSet1.Tables["Example"].Rows.RowState.ToString());

In despair I have tried all the combinations (before and after the line where I have tried to assign new value to the row):

dataSet1.AcceptChanges();
dataSet1.Tables["Example"].AcceptChanges()
dataSet1.Tables["Example"].Rows.AcceptChanges()

The result is always the same – I can’t change anything, and I remind you that when I try the same thing with DataGrid it works just fine.

Mine next guess was that DataGrid locks in some way Dataset (stupid guess, but I was desperate) and I’ve tried the whole thing without Dataset, but with no results again.

Mine guess is that I am not committing changes in a Dataset the way I should, but I can’t find a mistake.

Sorry for wasting your time.

Mine case is proof that it is good to leave the code when you are tired and to come back to it later on. I forgot to put the following line:

oleDbDataAdapter1.Update(dataSet1,”Example”)

While I was searching for some complex solutions I did not check basic things...