Click to See Complete Forum and Search --> : [RESOLVED] Data not being written to Datarow


soandos
September 5th, 2009, 07:37 PM
First I select a datarow using:

datarow[] rowtochange = datarow.select["ID = "+variable];

and the edit it with

rowtochange.beginedit();
rowtochange[0]["column_1"] = ... ;
.
.
.
rowtochange.endedit();
rowtochange.acceptchanges();


the data runs without error, and yet no data gets changed.
why is this?

using .net 3.5

JonnyPoet
September 6th, 2009, 04:01 PM
First I select a datarow using:

datarow[] rowtochange = datarow.select["ID = "+variable];

and the edit it with

rowtochange.beginedit();
rowtochange[0]["column_1"] = ... ;
.
.
.
rowtochange.endedit();
rowtochange.acceptchanges();


the data runs without error, and yet no data gets changed.
why is this?

using .net 3.5At first this code cannot work as you have case senstive errors in it like we normally would have AcceptChanges();
But acceptChanges is called after you have written back your data to the database using DataAdapter. So before calling AcceptChanges you need to update your database using that Adapter then when this has had success, you can use AcceptChanges() If you accept the chages all the internal flags that data have changed are cancelled so the database seems to be up to date and when you try to update Database after calling AcceptChanges() it will not find any Recordset that is known as changed.

soandos
September 6th, 2009, 07:37 PM
Thank you very much.