次の方法で共有


OdbcCommand.ResetCommandTimeout メソッド

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

CommandTimeout プロパティを既定値にリセットします。

Public Sub ResetCommandTimeout()
[C#]
public void ResetCommandTimeout();
[C++]
public: void ResetCommandTimeout();
[JScript]
public function ResetCommandTimeout();

解説

CommandTimeout の既定値は 30 秒です。

使用例

[Visual Basic, C#, C++] OdbcCommand の作成と CommandTimeout の設定を行った後で、プロパティを表示し、 CommandTimeout をリセットしてから、もう一度プロパティを表示する例を次に示します。この例では、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.CommandTimeout = 15
    MessageBox.Show(myCommand.CommandTimeout.ToString())
    myCommand.ResetCommandTimeout()
    MessageBox.Show(myCommand.CommandTimeout.ToString())
End Sub

[C#] 
public void CreateMyOdbcCommand(string mySelectQuery, string myConnectionString) 
{
   OdbcConnection myConnection = new OdbcConnection(myConnectionString);
   OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
   myCommand.CommandTimeout = 15;
   MessageBox.Show(myCommand.CommandTimeout.ToString());
   myCommand.ResetCommandTimeout();
   MessageBox.Show(myCommand.CommandTimeout.ToString());
}

[C++] 
public:
    void CreateMyOdbcCommand(String* mySelectQuery, String* myConnectionString)
    {
        OdbcConnection* myConnection = new OdbcConnection(myConnectionString);
        OdbcCommand* myCommand = new OdbcCommand(mySelectQuery, myConnection);

        myCommand->CommandTimeout = 15;
        MessageBox::Show(String::Concat(S"Command timeout: ", __box(myCommand->CommandTimeout)));

        myCommand->ResetCommandTimeout();
        MessageBox::Show(String::Concat(S"Command timeout: ", __box(myCommand->CommandTimeout)));

    };

[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 名前空間