DB2 10.5 for Linux, UNIX, and Windows

DB2Command Constructor (String, DB2Connection)

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

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

Syntax

[Visual Basic]
Public Sub New( _
   ByVal cmdText As String, _
   ByVal connection As DB2Connection _
)
[C#]
public DB2Command(
   string cmdText,
   DB2Connection connection
);
[C++]
public: DB2Command(
   String* cmdText,
   DB2Connection * connection
);
[JScript]
public function DB2Command(
   cmdText : String,
   connection : DB2Connection
);

Parameters

cmdText
The text of the query.
connection
A DB2Connection object that represents a connection to a data server.

Example

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

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

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