RowState Question



Hi folks,

I'm reading through David Sceppa's excellent ADO.NET book, trying to
teach myself ADO.NET, and have a question about the RowState property.

If I add a new row to a DataTable, it has a RowState of 'Added'.

If I modify an existing row, its RowState is 'Modified'.

If I add a row, but before I call AcceptChanges I modify that row, is it
still 'Added'?

I guess it has to be ... but what happens to the data I first entered
into the row that I might have overwritten with the subsequent edit?

Just trying to get a handle on how this stuff fits together :)



Fantastic! Thanks Markus.
Hi Matt,

I also read Sceppa's excellent ADO.NET book and had the same problem as you
getting the hang of the rowstates. Reading the .NET Framework documentation
didn't clear things up either, so finally I sat down and did some testing to
see if I could figure out what was really going on (see attached Excel

To answer your direct question, an 'Added' row will not change to 'Modified'
when you change it. Think of it this way, since an 'Added' row hasn't been
inserted into your database table yet, it can't really be modified. The row
will be stored in the database using INSERT even if you change it a hundered
times before updating.

In the attached Excel sheet you can also see for example that a row which
has rowstate 'Detached' behaves differently depending on if it is newly
created or if it has been added and then removed from a DataTable. I think
that maybe 'Detached' should have been split into two states - 'New' and

Hopes this helps,


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question