• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

Stop SqlDataAdapter Update() method

Hi Experts

I am updating my database using multithreading. The method used is the SqlDataAdapter.Update(). If the user presses cancel, I would like to stop the operation. For this I handle the RowUpdated event of the adapter but does anyone know how to stop the adapter Update() method?

Thanks
TheAvenger
0
TheAvenger
Asked:
TheAvenger
  • 4
  • 4
1 Solution
 
tomvergoteCommented:
you could add an eventhandler to the dataset onupdate event
0
 
TheAvengerAuthor Commented:
I have the event, it's ok. How to stop the adapter? Because I catch the event, but the adapter will still go on after I handle it.
0
 
tomvergoteCommented:
hmm, I posted the previous comment without looking at docs or code, and apparently dataset or dataadapter doesn't have an update event.
what event are you using?

If you update through a dataset, what happens if you call a dataset.acceptchanges.
I'll be on my dev machine in a bit, i'll be able to check my posts better but for now bear with me please

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
TheAvengerAuthor Commented:
I can't call AcceptChanges, because this will disallow a second save attempt. I use the RowUpdated event of the data adapter and it fires just fine after every row is updated - perfect place to stop the udpate operation. The only question is how.
0
 
tomvergoteCommented:
sorry i meant rejectchanges
yikes
0
 
TheAvengerAuthor Commented:
It's the same: both AcceptChanges and RejectChanges will change the dataset so, that a second attempt to update the database will consider that no records need update. Also RejectChanges will lose everything the user made, so both don't work.
0
 
tomvergoteCommented:
according to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaddingremovingadonetproviderevents.asp

you could either cancel it with an error or skip rows (which if i understand you correctly would have the same effect as cancelling)
0
 
TheAvengerAuthor Commented:
Now, this was a good one!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now