DB2 10.5 for Linux, UNIX, and Windows

DB2Command.CommandTimeout property

Gets or sets the wait time before the client terminates 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. A value of 0 specifies no limit to the wait time, rather than no wait time.

Exceptions

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

Remarks

The DB2Command.CommandTimeout property does not apply to XA control operations, which include operations such as xa_open and xa_prepare.

Example

[Visual Basic, C#] The following example creates a DB2Command object 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;
}