Solved

Stop SqlDataAdapter Update() method

Posted on 2004-10-15
8
333 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
[X]
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
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

695 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