SqlCeDataAdapter.SelectCommand Property

Gets or sets an SQL statement used to select records in the data source.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)


Public Property SelectCommand As SqlCeCommand
Dim instance As SqlCeDataAdapter
Dim value As SqlCeCommand

value = instance.SelectCommand

instance.SelectCommand = value
public SqlCeCommand SelectCommand { get; set; }
property SqlCeCommand^ SelectCommand {
    SqlCeCommand^ get ();
    void set (SqlCeCommand^ value);
member SelectCommand : SqlCeCommand with get, set
function get SelectCommand () : SqlCeCommand
function set SelectCommand (value : SqlCeCommand)

Property Value

Type: System.Data.SqlServerCe.SqlCeCommand
A SqlCeCommand that is used during Fill to select records from data source for placement in the DataSet.


When SelectCommand is assigned to a previously-created SqlCeCommand, the SqlCeCommand is not cloned. The SelectCommand maintains a reference to the previously-created SqlCeCommand object.

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


The following example creates a SqlCeDataAdapter and sets some of its properties.

Dim da As New SqlCeDataAdapter()

Dim conn As New SqlCeConnection("Data Source = MyDatabase.sdf")
Dim cmd As New SqlCeCommand("SELECT * FROM Customers WHERE Country = @country", conn)

cmd.Parameters.Add("@country", SqlDbType.NVarChar, 15)
cmd.Parameters(0).Value = "UK"

da.SelectCommand = cmd
SqlCeDataAdapter da = new SqlCeDataAdapter();

SqlCeConnection conn = new SqlCeConnection("Data Source = MyDatabase.sdf");
SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Customers WHERE Country = @country", conn);

cmd.Parameters.Add("@country", SqlDbType.NVarChar, 15);
cmd.Parameters[0].Value = "UK";

da.SelectCommand = cmd;

See Also


SqlCeDataAdapter Class

System.Data.SqlServerCe Namespace