I run a longtime running SQL query by clicking on GO button:
Await cmd.ExecuteNonQueryAsync(Me.cts.Token)
The command starts, lets say I have this query as part of corresponding command:
set nocount on;
declare @ID int=0
WHILE @ID<400000 BEGIN
SET @ID+=1
WAITFOR DELAY '00:00:01.000'
END
Now when I click Cancel button (which call cts.Cancel()
) it causes SqlException, whichs containts 2 errors:
- “A severe error occurred on the current command. The results, if any, should be discarded.” (number 0)
- “Operation cancelled by user.” (number 0)
I also different queries including INSERT statements. Everything worked fine, data was properly written.
So what is wrong?