DB2 Version 10.1 for Linux, UNIX, and Windows

DB2Command.CommandTimeout Property

Gets or sets the wait time before terminating the attempt to execute a command, or the execution of a command. An error is generated after termination.

Namespace:
IBM®.Data.DB2®
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax

[Visual Basic]
Public Property CommandTimeout As Integer
[C#]
public int CommandTimeout {get; set;}
[C++]
public: __property int get_CommandTimeout();
public: __property void set_CommandTimeout(int);
[JScript]
public function get CommandTimeout() : int;
public function set CommandTimeout(int);

Property value

The time (in seconds) to wait for the command to execute. The default is 30 seconds.

Exceptions

Exception type Condition
ArgumentException The property value assigned is less than 0.

Remarks

A value of zero (0) specifies no limit to the wait time, rather than no wait time, and therefore should be avoided.

Example

[Visual Basic, C#] The following example creates a DB2Command and sets some of its properties.

[Visual Basic]
Public Sub CreateMyDB2Command()
    Dim mySelectQuery As String = "SELECT * FROM EMPLOYEE ORDER BY EMPNO"
    Dim myCommand As New DB2Command(mySelectQuery)
    myCommand.CommandTimeout = 20
End Sub

[C#]
public void CreateMyDB2Command()
{
   string mySelectQuery = "SELECT * FROM EMPLOYEE ORDER BY EMPNO";
   DB2Command myCommand = new DB2Command(mySelectQuery);
   myCommand.CommandTimeout = 20;
}