次の方法で共有


OdbcCommand.Cancel メソッド

メモ : この名前空間、クラス、およびメンバは、.NET Framework Version 1.1 だけでサポートされています。

OdbcCommand の実行のキャンセルを試行します。

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

実装

IDbCommand.Cancel

解説

キャンセルする処理が存在しない場合は、何も発生しません。ただし、実行中のコマンドがある場合にキャンセルが失敗すると、例外は生成されません。

使用例

[Visual Basic, C#, C++] OdbcCommand を作成し、実行してから、その実行をキャンセルする例を次に示します。この例では、SQL SELECT ステートメントの文字列と、データ ソースに接続するために使用する文字列をメソッドに渡します。

 
Public Sub CreateMyOdbcCommand _
(mySelectQuery As String, myConnectionString As String)
    Dim myConnection As New OdbcConnection(myConnectionString)
    Dim myCommand As New OdbcCommand(mySelectQuery, myConnection)
    myCommand.Connection.Open()
    myCommand.ExecuteReader()
    myCommand.Cancel()
End Sub

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

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

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

OdbcCommand クラス | OdbcCommand メンバ | System.Data.Odbc 名前空間