Is there a way to make DataAdapter not call Acceptchanges after Update Method

  • Thread starter Thread starter jkang4
  • Start date Start date
J

jkang4

Hi,

Here is the problem I'm facing.
I'm working on a system where I need to make DataAdapter.Update method
call to update the database. After the update is complete I need to
make a call to an external system. (I know it's not the prettiest
picture but for now I do need to update the database before I make the
external system call, because in our current design our handler that
make external system calls gather this updated information from
different tables in the DB)

The problem is the external system might return an error and I'd need
to roll back my changes to the DB earlier.

I do the update using Update Method in the DataAdapter. It would be
great if I could make DataAdapter not to call AcceptChanges so I can
call RejectChanges on the dataset and update back to the DB. Is there
a way to do this?

Thanks in advance for your help.

Jin
 
I don't believe there is. What you could do, is make a copy of the dataset
by calling GetChanges, and use that copy later on for your other update.
 
Hi Marina,
I don't believe there is. What you could do, is make a copy of the dataset
by calling GetChanges, and use that copy later on for your other update.

Is that not answering with "Yes there is", what does it not as asked, it
preserves the updates whatever the dataadpater does with it.

:-)))

Cor
 
Making a copy of the datasst is probably the simplest solution.

Another idea:
Can't you use Distributed Transaction Coordinator in COM+ for this?
 
Jin,

If you want to keep the DataAdapter from implicitly calling
AcceptChanges after submitting the pending changes in a row,
handle the DataAdapter's RowUpdated event and set
RowUpdatedEventArgs to UpdateStatus.SkipCurrentRow.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2004 Microsoft Corporation. All rights reserved.
 
No, it is quite different. There is no way to make the dataadapter not call
AcceptChanges on the dataset it just updated. No matter what you do, it
will always make this call.

What I suggested was a workaround for this problem.
 
Ok Ok however you gave the right answer on the explicit question in my
opinion.

Another thing is that I thought that when you do a update as this

myAdapter.update(dataset.getchanges)

the acceptchanges is not done (was more a problem I once had)

However some time ago, so do not shoot me when I am wrong.

:-)

Cor
 
Back
Top