DB2Command Constructor

Initializes a new instance of the DB2Command class.

Public Constructors

Name Description
DB2®Command()

Initializes a new instance of the DB2Command class.

DB2Command(String)

Initializes a new instance of the DB2Command class with the text of the query.

DB2Command(String, DB2Connection)

Initializes a new instance of the DB2Command class with the text of the query and a DB2Connection object.

DB2Command(String, DB2Connection, DB2Transaction)

Initializes a new instance of the DB2Command class with the text of the query, a DB2Connection object, and the Transaction.

Example

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

Note: [Visual Basic, C#] This example shows how to use one of the overloaded versions of the DB2Command constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic]
Public Sub CreateMyDB2Command()
    Dim myConnection As New DB2Connection _
       ("DATABASE=SAMPLE")
    myConnection.Open()
    Dim myTrans As DB2Transaction = myConnection.BeginTransaction()
    Dim mySelectQuery As String = _
       "SELECT * FROM EMPLOYEE ORDER BY EMPNO"
    Dim myCommand As New DB2Command(mySelectQuery, myConnection, myTrans)
    myCommand.CommandTimeout = 20
End Sub

[C#]
public void CreateMyDB2Command()
{
   DB2Connection myConnection = new DB2Connection("DATABASE=SAMPLE");
   myConnection.Open();
   DB2Transaction myTrans = myConnection.BeginTransaction();
   string mySelectQuery = "SELECT * FROM EMPLOYEE ORDER BY EMPNO";
   DB2Command myCommand = new DB2Command(mySelectQuery, myConnection,myTrans);
   myCommand.CommandTimeout = 20;
}