Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Cancel Method

OracleCommand.Cancel Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Attempts to cancel the execution of an OracleCommand.

[Visual Basic]
Public Overridable Sub Cancel() Implements IDbCommand.Cancel
[C#]
public virtual void Cancel();
[C++]
public: virtual void Cancel();
[JScript]
public function Cancel();

Implements

IDbCommand.Cancel

Remarks

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

Example

[Visual Basic, C#, C++] The following example creates an OracleCommand, executes it, 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 database.

[Visual Basic] 
Public Sub CreateMyOracleCommand _
(mySelectQuery As String, myConnectionString As String)
    Dim myConnection As New OracleConnection(myConnectionString)
    Dim myCommand As New OracleCommand(mySelectQuery, myConnection)
    myCommand.Connection.Open()
    myCommand.ExecuteReader()
    myCommand.Cancel()
End Sub

[C#] 
public void CreateMyOracleCommand(string mySelectQuery, string myConnectionString) 
{
   OracleConnection myConnection = new OracleConnection(myConnectionString);
   OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection);
   myCommand.Connection.Open();
   myCommand.ExecuteReader();
   myCommand.Cancel();
}

[C++] 
public:
 void CreateMyOracleCommand(String* mySelectQuery, String* myConnectionString) 
 {
    OracleConnection* myConnection = new OracleConnection(myConnectionString);
    OracleCommand* myCommand = new OracleCommand(mySelectQuery, myConnection);
    myCommand->Connection->Open();
    myCommand->ExecuteReader();
    myCommand->Cancel();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleCommand Class | OracleCommand Members | System.Data.OracleClient Namespace

Show:
© 2015 Microsoft