views:

118

answers:

1

Hello All,

I am running a long running stored procedure that user can cancel. I am using Backgroundworker component along with BeginExecuteReader method of ado.net

everything seems to work fine, but even when i cancel the stored procedure, the database is still running the proc

Is there a way to cancel the actual job on the database server itself ? I can see that we can use kill command, but that needs the job id.

thanks

+2  A: 

SqlCommand.Cancel

Chris Pebble
that worked, but as soon as i cancel it, it calls the callback method, and throws exceptions saying "A severe error occured on the current command .". Is there a way to check if the command was cancelled ? the is Completed property of the IAsyncResult is true until EndExecuteReader method is called.