DataTable doesn't see modified rows when bound to ctrls

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi,

I'm binding a DataTable to several controls and everything
seems to be reflected okay. When comes to updating the
database, I'm calling DataTable's Select(string.Empty,
string.Empty, DataViewRowState.ModifiedCurrent) and
passing this DataRow[] into SqlDataAdapter's Update()
method.

Unfortunately, Select() doesn't seem to see modified
values as modified values because it's returning a DataRow
[] with zero elements.

This leads me to believe that when a control updates the
DataTable, it calls the DataTable's AcceptChanges()
method. How do I prevent this from happening?

Thanks,
Paul
 
why are you not updating your databse like this.

sqlDatadapter.update(dataset) ?

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
 
OK, i didnt realise that. I know that the update method implicity calls
acceptChanges after the update. maybe it is also implicit with the controls
in the mode you are using in in which case I'm not sure.

Sorry, I could not be of more help

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
Paul said:
This is very simple. Update() has to be called in a
proper sequence since the DataSet contains several related
tables. Adding and modifying rows have to done from the
top down, whereas deleting rows must be done from the
bottom up.

-----Original Message-----
why are you not updating your databse like this.

sqlDatadapter.update(dataset) ?

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
Paul said:
Hi,

I'm binding a DataTable to several controls and everything
seems to be reflected okay. When comes to updating the
database, I'm calling DataTable's Select(string.Empty,
string.Empty, DataViewRowState.ModifiedCurrent) and
passing this DataRow[] into SqlDataAdapter's Update()
method.

Unfortunately, Select() doesn't seem to see modified
values as modified values because it's returning a DataRow
[] with zero elements.

This leads me to believe that when a control updates the
DataTable, it calls the DataTable's AcceptChanges()
method. How do I prevent this from happening?

Thanks,
Paul


.
 
This is very simple. Update() has to be called in a
proper sequence since the DataSet contains several related
tables. Adding and modifying rows have to done from the
top down, whereas deleting rows must be done from the
bottom up.

-----Original Message-----
why are you not updating your databse like this.

sqlDatadapter.update(dataset) ?

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
Paul said:
Hi,

I'm binding a DataTable to several controls and everything
seems to be reflected okay. When comes to updating the
database, I'm calling DataTable's Select(string.Empty,
string.Empty, DataViewRowState.ModifiedCurrent) and
passing this DataRow[] into SqlDataAdapter's Update()
method.

Unfortunately, Select() doesn't seem to see modified
values as modified values because it's returning a DataRow
[] with zero elements.

This leads me to believe that when a control updates the
DataTable, it calls the DataTable's AcceptChanges()
method. How do I prevent this from happening?

Thanks,
Paul


.
 
Back
Top