add STOP button, to cancel the query process

M

mttc

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?
 
P

Pablo Castro [MS]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top