How to force DataAdapter NOT to update added rows?

D

Dmitry Karneyev

Hi!
I've got a DataSet with tables corresponding to the database ones.
And I've got a table for my calculations and databinding in app.
To fill "my" table I use myTable.Rows.Add(...) and then edit necessary
columns.
When app closes I check dataset.HasChanges() and if it is I make an update.
But HasChanges always returns true because I've got added rows to "myTable".
How to avoid such situation? Or how to change status of "myTable" rows to
original?

Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

Dmitry,

If possible, you will want to add all of the rows you need first and
then call AcceptChanges. This will have the effect of changing the state of
the rows to unchanged, and then you can perform your edits. The only change
in the tables will then be the edits, and HasChanges will give you the
result that you want.

Hope 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

Top