Επεξεργασία

Κοινή χρήση μέσω


OleDbCommand.Cancel Method

Definition

Tries to cancel the execution of an OleDbCommand.

public:
 override void Cancel();
public:
 virtual void Cancel();
public override void Cancel ();
public void Cancel ();
override this.Cancel : unit -> unit
abstract member Cancel : unit -> unit
override this.Cancel : unit -> unit
Public Overrides Sub Cancel ()
Public Sub Cancel ()

Implements

Examples

The following example creates an OleDbCommand, executes it, and then cancels the execution. To accomplish this, the method is passed a string that is an SQL SELECT statement and a string to use to connect to the data source.

public void CreateCommand(string queryString, OleDbConnection connection)
{
    OleDbCommand command = new OleDbCommand(queryString, connection);
    command.Connection.Open();
    command.ExecuteReader();
    command.Cancel();
}
Public Sub CreateCommand _
    (ByVal queryString As String, ByVal connection As OleDbConnection)

    Dim command As New OleDbCommand(queryString, connection)
    command.Connection.Open()
    command.ExecuteReader()
    command.Cancel()
End Sub

Remarks

If there is nothing to cancel, nothing occurs. However, if there is a command in process, and the attempt to cancel fails, no exception is generated.

Applies to

See also