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)

Syntax

'Declaration
Public Property SelectCommand As SqlCeCommand
public SqlCeCommand SelectCommand { get; set; }
public:
property SqlCeCommand^ SelectCommand {
    SqlCeCommand^ get ();
    void set (SqlCeCommand^ value);
}
/** @property */
public SqlCeCommand get_SelectCommand ()

/** @property */
public void set_SelectCommand (SqlCeCommand value)
public function get SelectCommand () : SqlCeCommand

public function set SelectCommand (value : SqlCeCommand)

Property Value

A SqlCeCommand that is used during Fill to select records from data source for placement in the DataSet.

Remarks

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.

Example

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;

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
Version Information
.NET Framework and NET Compact Framework
Supported in 3.5
.NET Framework
Supported in 3.0
.NET Compact Framework and .Net Framework
Supported in 2.0

See Also

Reference

SqlCeDataAdapter Class
SqlCeDataAdapter Members
System.Data.SqlServerCe Namespace
SqlCeDataAdapter.DeleteCommand Property
SqlCeDataAdapter.InsertCommand Property
UpdateCommand