OnQueryCancel Event (DTS)

The OnQueryCancel Event terminates tasks. A package calls this event only when it is safe to stop execution of the task. If Cancel is TRUE, stop execution and fail with error. Note that this event may not occur if execution of the step or task completes quickly.

Applies To

Package Object

Syntax

object.OnQueryCancel(
EventSource,
pbCancel)

Part Description
Package Expression that evaluates to an object in the Applies To list
EventSource Event being executed
pbCancel Whether to cancel task execution

Remarks

If Cancel is TRUE, package execution stops and an error is returned. This event may not occur if execution of the step or task completes quickly.

In certain circumstances, it may not be possible to use OnQueryCancel to cancel the execution of a Task. For example, if an attempt is made to insert a table into itself using the Microsoft OLE DB Provider object for SQL Server, the destination connection begins a bulk copy transaction. After the source retrieves all rows up to the first destination row inserted, where the transaction began, an attempt to retrieve the next row from the source blocks on the destination connection. A similar situation also can occur if a user has an exclusive lock on a page that the DTS SPID requires.

To resolve the situation in which the data pump task encounters a block, you must terminate the SPID.

For task types defined by DTS, the EventSource argument indicates a task by name. DTS tasks can be unnamed. When an unnamed task raises an OnQueryCancel event, the EventSource argument is empty.

Prototype (C/C++)

HRESULT OnQueryCancel(BSTR EventSource,
BOOL *pbCancel);

See Also
KILL  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.