Datatable updating pb...

  • Thread starter Thread starter fh
  • Start date Start date
F

fh

Hello,

I modifie one row of a datatable
with this code

DataRow drCurent = _dsDowntime.Tables["PPE_DOWNTIME"].Rows[numRow];
drCurent.BeginEdit();
drCurent["Automatic"]=txbCAuto.Text;
drCurent["DowntimeStart"]=txbbeg.Text;
drCurent["DowntimeEnd"]=txbEnd.Text;
drCurent.EndEdit();

but i can't see any change when i reload the data
even if i ask for their current state

Any help please
Franck
 
thanks for your answer
but when I wrote, reload the data,
I meant from the dataset modified (apprently not...)

Eliyahu said:
Franck,

EndEdit doesn't save data to the database, it just ends the edit occuring on
the row.

Eliyahu

fh said:
Hello,

I modifie one row of a datatable
with this code

DataRow drCurent = _dsDowntime.Tables["PPE_DOWNTIME"].Rows[numRow];
drCurent.BeginEdit();
drCurent["Automatic"]=txbCAuto.Text;
drCurent["DowntimeStart"]=txbbeg.Text;
drCurent["DowntimeEnd"]=txbEnd.Text;
drCurent.EndEdit();

but i can't see any change when i reload the data
even if i ask for their current state

Any help please
Franck
 
Eliyahu said:
You lneed to call AcceptChanges method on either DataRow or DataTable or
DataSet.
DataRow drCurent = _dsDowntime.Tables["PPE_DOWNTIME"].Rows[numRow];
drCurent.BeginEdit();
drCurent["Automatic"]=txbCAuto.Text;
drCurent["DowntimeStart"]=txbbeg.Text;
drCurent["DowntimeEnd"]=txbEnd.Text;
drCurent.EndEdit();

thanks for your answer
I have added the folowing line to my code

drCurent.AcceptChanges();
bool test = _dsDowntime.HasChanges();

test returned false....


The following is from the MSDN Library topic:

You can confirm edits by calling EndEdit or you can cancel them by calling
CancelEdit. Note that while EndEdit does confirm your edits, the DataSet
does not actually accept the changes until AcceptChanges is called. Note
also that if you call AcceptChanges before you have ended the edit with
EndEdit or CancelEdit, the edit is ended and the Proposed row values are
accepted for both the Current and Original row versions. In the same manner,
calling RejectChanges ends the edit and discards the Current and Proposed
row versions. Calling EndEdit or CancelEdit after calling AcceptChanges or
RejectChanges has no effect because the edit has already ended.


Eliyahu

fh said:
thanks for your answer
but when I wrote, reload the data,
I meant from the dataset modified (apprently not...)

occuring on
the row.

Eliyahu

"fh" <[email protected]> wrote in message
Hello,

I modifie one row of a datatable
with this code

DataRow drCurent = _dsDowntime.Tables["PPE_DOWNTIME"].Rows[numRow];
drCurent.BeginEdit();
drCurent["Automatic"]=txbCAuto.Text;
drCurent["DowntimeStart"]=txbbeg.Text;
drCurent["DowntimeEnd"]=txbEnd.Text;
drCurent.EndEdit();

but i can't see any change when i reload the data
even if i ask for their current state

Any help please
Franck
 
Franck,

EndEdit doesn't save data to the database, it just ends the edit occuring on
the row.

Eliyahu
 
You lneed to call AcceptChanges method on either DataRow or DataTable or
DataSet.

The following is from the MSDN Library topic:

You can confirm edits by calling EndEdit or you can cancel them by calling
CancelEdit. Note that while EndEdit does confirm your edits, the DataSet
does not actually accept the changes until AcceptChanges is called. Note
also that if you call AcceptChanges before you have ended the edit with
EndEdit or CancelEdit, the edit is ended and the Proposed row values are
accepted for both the Current and Original row versions. In the same manner,
calling RejectChanges ends the edit and discards the Current and Proposed
row versions. Calling EndEdit or CancelEdit after calling AcceptChanges or
RejectChanges has no effect because the edit has already ended.


Eliyahu

fh said:
thanks for your answer
but when I wrote, reload the data,
I meant from the dataset modified (apprently not...)

Eliyahu said:
Franck,

EndEdit doesn't save data to the database, it just ends the edit occuring on
the row.

Eliyahu

Hello,

I modifie one row of a datatable
with this code

DataRow drCurent = _dsDowntime.Tables["PPE_DOWNTIME"].Rows[numRow];
drCurent.BeginEdit();
drCurent["Automatic"]=txbCAuto.Text;
drCurent["DowntimeStart"]=txbbeg.Text;
drCurent["DowntimeEnd"]=txbEnd.Text;
drCurent.EndEdit();

but i can't see any change when i reload the data
even if i ask for their current state

Any help please
Franck
 
Naturally enough. If you check HasChanges() before AcceptChanges(), it
should return true. AcceptChanges() resets everything as if no changes
occured. I think, even if you call it for a datarow, it accepts the row
change all the way up to the dataset.

Eliyahu

fh said:
Eliyahu said:
You lneed to call AcceptChanges method on either DataRow or DataTable or
DataSet.
DataRow drCurent = _dsDowntime.Tables["PPE_DOWNTIME"].Rows[numRow];
drCurent.BeginEdit();
drCurent["Automatic"]=txbCAuto.Text;
drCurent["DowntimeStart"]=txbbeg.Text;
drCurent["DowntimeEnd"]=txbEnd.Text;
drCurent.EndEdit();

thanks for your answer
I have added the folowing line to my code

drCurent.AcceptChanges();
bool test = _dsDowntime.HasChanges();

test returned false....


The following is from the MSDN Library topic:

You can confirm edits by calling EndEdit or you can cancel them by calling
CancelEdit. Note that while EndEdit does confirm your edits, the DataSet
does not actually accept the changes until AcceptChanges is called. Note
also that if you call AcceptChanges before you have ended the edit with
EndEdit or CancelEdit, the edit is ended and the Proposed row values are
accepted for both the Current and Original row versions. In the same manner,
calling RejectChanges ends the edit and discards the Current and Proposed
row versions. Calling EndEdit or CancelEdit after calling AcceptChanges or
RejectChanges has no effect because the edit has already ended.


Eliyahu

thanks for your answer
but when I wrote, reload the data,
I meant from the dataset modified (apprently not...)

Eliyahu Goldin wrote:

Franck,

EndEdit doesn't save data to the database, it just ends the edit

occuring on
the row.

Eliyahu


Hello,

I modifie one row of a datatable
with this code

DataRow drCurent = _dsDowntime.Tables["PPE_DOWNTIME"].Rows[numRow];
drCurent.BeginEdit();
drCurent["Automatic"]=txbCAuto.Text;
drCurent["DowntimeStart"]=txbbeg.Text;
drCurent["DowntimeEnd"]=txbEnd.Text;
drCurent.EndEdit();

but i can't see any change when i reload the data
even if i ask for their current state

Any help please
Franck
 
Back
Top