Solved

Stop SqlDataAdapter Update() method

Posted on 2004-10-15
8
327 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now