DB2 Version 10.1 for Linux, UNIX, and Windows

DB2DataAdapter.SelectCommand Property

Gets or sets an SQL statement or stored procedure used to select records in the database.

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

Syntax

[Visual Basic]
Public Property SelectCommand As DB2Command

[C#]
public new DB2Command
 SelectCommand {get; set;}
[C++]
public: __property DB2Command
* get_SelectCommand();
public: __property void set_SelectCommand(DB2Command
*);
[JScript]
public function get SelectCommand() : DB2Command
;
public function set SelectCommand(DB2Command
);

Property value

A DB2Command that is used during a fill operation to select records from database for placement in the DataSet.

Remarks

When SelectCommand is assigned to a previously created DB2Command , the DB2Command is not cloned. Instead, the SelectCommand maintains a reference to the previously created DB2Command object.

If SelectCommand does not return any rows, no tables are added to the DataSet, and no exception is raised.

Example

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

[Visual Basic]
Public Sub CreateDB2DataAdapter()
     Dim myConnection As DB2Connection = New DB2Connection("DATABASE=SAMPLE")
     Dim myDataAdapter As New DB2DataAdapter()
     Dim mySelectCommand As New DB2Command()
     myDataAdapter.SelectCommand.CommandText = _
        "SELECT * FROM STAFF ORDER BY ID"
 End Sub

[C#]
public void CreateDB2DataAdapter () {
    DB2Connection myConnection = new DB2Connection("DATABASE=SAMPLE");
    DB2DataAdapter myDataAdapter = new DB2DataAdapter();
    DB2Command mySelectCommand = new DB2Command();
    myDataAdapter.SelectCommand.CommandText = "SELECT * FROM STAFF ORDER BY ID";
}