DataSet.RejectChanges() doesn't work!

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
 
P

Peter Koen

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------
 
S

Saso Zagoranski

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

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