DataSet.RejectChanges() doesn't work!

  • Thread starter Thread starter Saso Zagoranski
  • Start date Start date
S

Saso Zagoranski

Hi again!

I have two DataSets... I add some data to both of the dataset and the I
call:
dataAdapter1.Update(dataSet1);
dataAdapter2.Update(dataSet2);

if there is an exception in any of the two dataset I want ALL the data to be
discarded, so I call:
try
{
...
}
catch
{
dataSet1.RejectChanges();
dataSet2.RejectChanges();
}

The problem is, that if I get an exception updating the second dataset
(dataSet2) the data in dataSet1 is stored in the
database despite the fact that I call dataSet1.RejectChanges()...

What am I doing wrong?

Thank,
saso
 
The problem is, that if I get an exception updating the second dataset
(dataSet2) the data in dataSet1 is stored in the
database despite the fact that I call dataSet1.RejectChanges()...

What am I doing wrong?

Nothing, this is by design. When you call Update and there is no error then
the values will be written to the database and AcceptChanges will be called
on the datatable.

When you want to updat both or neither dataset you will have to use
transactions. That'S your only chance to get a consistent database.

greets
Peter

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
I don't have any experience with transactions... where can I get some
introductory reading on this topic?
Can you give me some advice?
 
Back
Top