dotConnect for DB2 Documentation
Devart.Data.DB2 Namespace / DB2Command Class / DB2Command Constructor / DB2Command Constructor(String,DB2Connection,DB2Transaction)
The text of the query.
A DB2Connection object that represents the connection to DB2.
DB2Transaction object used to perform transactions with this DB2Command object.
Example

In This Topic
    DB2Command Constructor(String,DB2Connection,DB2Transaction)
    In This Topic
    Initializes a new instance of the DB2Command class with the text of the query, a %% object, and the DB2Transaction.
    Syntax
    'Declaration
     
    Public Function New( _
       ByVal commandText As String, _
       ByVal connection As DB2Connection, _
       ByVal transaction As DB2Transaction _
    )
    public DB2Command( 
       string commandText,
       DB2Connection connection,
       DB2Transaction transaction
    )

    Parameters

    commandText
    The text of the query.
    connection
    A DB2Connection object that represents the connection to DB2.
    transaction
    DB2Transaction object used to perform transactions with this DB2Command object.
    Remarks
    The following table shows initial property values for an instance of this implementation of the DB2Command.
    Properties Initial value
    CommandText commandText
    CommandTimeout 30
    CommandType System.Data.CommandType.Text
    Connection connection

    You can change the value for any of these parameters by setting the related property.

    Example
    The following example creates a DB2Command and sets some of its properties.
    public void CreateCommand()
    {
      DB2Connection db2Connection = new DB2Connection(
          "user id=db2admin;server=db2;database=SAMPLE;");
      db2Connection.Open();
      DB2Transaction myTrans = db2Connection.BeginTransaction();
      string mySelectQuery = "SELECT * FROM Dept";
      DB2Command db2Command = new DB2Command(mySelectQuery, db2Connection,myTrans);
      db2Command.FetchSize = 100
    }
    Public Sub CreateCommand()
      Dim db2Connection As New DB2Connection( _
        "user id=db2admin;server=db2;database=SAMPLE;")
      db2Connection.Open()
      Dim myTrans As DB2Transaction = db2Connection.BeginTransaction()
      Dim mySelectQuery As String = _
        "SELECT * FROM Dept"
      Dim db2Command As New DB2Command(mySelectQuery, db2Connection, myTrans)
      db2Command.FetchSize = 100
    End Sub
    See Also