OlsDbCommand.Cancel does not stop SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear Newsgroup
when I kick off stored procedure through an OleDbCommand, it seems impossible to stop it again. In a different thread, I call OleDbCommand.Cancel, but this call waits for the stored procedure to finish instead of killing it. Unlike SQL Query Analyzer, my c#-programm can not interrupt a running stored procedure

What's the trick ??
 
Hi Kay,

Cancel just tries to cancel the execution. Plus, I don't think that it is
thread safe.
As a workaround you might put your executeNonQuery into another thread and
Abort whole thread instead of just Cancel int the stored proc.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

kay said:
Dear Newsgroup,
when I kick off stored procedure through an OleDbCommand, it seems
impossible to stop it again. In a different thread, I call
OleDbCommand.Cancel, but this call waits for the stored procedure to finish
instead of killing it. Unlike SQL Query Analyzer, my c#-programm can not
interrupt a running stored procedure.
 
when I call abort, the thread sits there in state "AbortRequested" until SQL Server has finished the stored proc. The SQL is still unimpressed and keeps running... any other ideas ?
 
Hi kay,

Yes, don't wait for thread to finish. Just leave it.
It will finish as soon as sp ends its job.
Maybe I didn't stated clear enough that my solution won't end the stored
procedure. However it won't stop your program either.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

kay said:
when I call abort, the thread sits there in state "AbortRequested" until
SQL Server has finished the stored proc. The SQL is still unimpressed and
keeps running... any other ideas ?
 
how can the stored proc be aborted? Query analyzer can do it, so a dotnet program should be able to, too

Hmmm - I suspect it's Bug 325338
Microsoft eats my time - it took me more than a day to find that bug
I'll try "Mdac 2.7 SP1 refresh" ...
 
Back
Top