I have form that executes heavy Stored Procedure on sql 2000.
I want to add STOP button, to cancel the process.

I try to abort the thread. But this action not stops the process
Immediately. It?s take a long time until query cancel.

In the Query Analyzer I can kill the process at once
by disconnecting the window, it?s cause also to cancel the query.

How I can do something like from .NET code?
I try close Connection from Main thread, and nothing happened?

Re: add STOP button, to cancel the query process by Pablo

Pablo
Mon Dec 06 15:40:30 CST 2004

Did you take a look at the SqlCommand.Cancel method? It will cancel a
running query (if the server is in an stage of the query processing that can
be aborted). It's the only thread-safe method in ADO.NET, so you can call it
from another thread without any synchronization.

--
Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.


"mttc" <s@hotmail.com> wrote in message news:41b4c08d@news.012.net.il...
> I have form that executes heavy Stored Procedure on sql 2000.
> I want to add STOP button, to cancel the process.
>
> I try to abort the thread. But this action not stops the process
> Immediately. It?s take a long time until query cancel.
>
> In the Query Analyzer I can kill the process at once
> by disconnecting the window, it?s cause also to cancel the query.
>
> How I can do something like from .NET code?
> I try close Connection from Main thread, and nothing happened?
>
>



Re: add STOP button, to cancel the query process by BojanKuhar

BojanKuhar
Mon Apr 25 10:45:01 CDT 2005

How would one do that from presentation to middle tier?

"Pablo Castro [MS]" wrote:

> Did you take a look at the SqlCommand.Cancel method? It will cancel a
> running query (if the server is in an stage of the query processing that can
> be aborted). It's the only thread-safe method in ADO.NET, so you can call it
> from another thread without any synchronization.
>
> --
> Pablo Castro
> Program Manager - ADO.NET Team
> Microsoft Corp.
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "mttc" <s@hotmail.com> wrote in message news:41b4c08d@news.012.net.il...
> > I have form that executes heavy Stored Procedure on sql 2000.
> > I want to add STOP button, to cancel the process.
> >
> > I try to abort the thread. But this action not stops the process
> > Immediately. Itâ??s take a long time until query cancel.
> >
> > In the Query Analyzer I can kill the process at once
> > by disconnecting the window, itâ??s cause also to cancel the query.
> >
> > How I can do something like from .NET code?
> > I try close Connection from Main thread, and nothing happened?
> >
> >
>
>
>