I have some issues with cancelling the execution of a long-during sql-query.
Please take a look at the winforms-code below.
When I open up the SQL-Profiler, the execution of the query isn't cancelled by calling Cancel() on the command-object.
Does anyone have an idea, why not? Is it a feature which I have to enable on the sql-server?
public partial class Form1 : Form
private void Form1_Load(object sender, EventArgs e)
_commandText = "select * from HugeTable";
private void InitializeOpenedConnection()
if (_connection == null || _connection.State == ConnectionState.Closed)
_connection = new SqlConnection(GetConnectionString());
if (_connection.State != ConnectionState.Open)
private void btnStart_Click(object sender, EventArgs e)
_command = new SqlCommand(_commandText, _connection);
_result = _command.BeginExecuteReader();
_command.StatementCompleted += new StatementCompletedEventHandler(_command_StatementCompleted);
View Complete Post