Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Stop SqlDataAdapter Update() method

Posted on 2004-10-15
8
330 Views
Last Modified: 2008-02-01
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
Comment
Question by:TheAvenger
  • 4
  • 4
8 Comments
 
LVL 8

Expert Comment

by:tomvergote
ID: 12317576
you could add an eventhandler to the dataset onupdate event
0
 
LVL 20

Author Comment

by:TheAvenger
ID: 12317582
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
 
LVL 8

Expert Comment

by:tomvergote
ID: 12317639
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 20

Author Comment

by:TheAvenger
ID: 12317654
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
 
LVL 8

Expert Comment

by:tomvergote
ID: 12317667
sorry i meant rejectchanges
yikes
0
 
LVL 20

Author Comment

by:TheAvenger
ID: 12317675
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
 
LVL 8

Accepted Solution

by:
tomvergote earned 250 total points
ID: 12317758
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
 
LVL 20

Author Comment

by:TheAvenger
ID: 12318545
Now, this was a good one!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question