Delen via


SqlCeCommand.CommandText Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets or sets an SQL statement to execute at the data source.

  [Visual Basic]
  Public Overridable Property CommandText As String  Implements _
   IDbCommand.CommandText
[C#]
public virtual string CommandText {get; set;}
[C++]
public: __property virtual String* get_CommandText();
public: __property virtual void set_CommandText(String*);
[JScript]
public function get CommandText() : String;
public function set CommandText(String);

Property Value

The SQL statement to execute or the name of the base table to open. The default value is an empty string.

Implements

IDbCommand.CommandText

Remarks

When the CommandType property is set to TableDirect, the CommandText property should be set to the name of the table to be accessed. TableDirect access is the fastest way to retrieve data from SQL Server CE. You may be required to use escape character syntax if any of the tables named contain any special characters. All rows and columns of the named table or tables will be returned when you call one of the Execute methods.

You cannot set the Connection, CommandType, and CommandText properties if the current connection is performing an Execute or Fetch operation.

The .NET Compact Framework data provider for SQL Server CE does not support named parameters for passing parameters to an SQL statement called by a SqlCeCommand when CommandType is set to Text. You must use the question mark (?) placeholder. For example: SELECT * FROM Customers WHERE CustomerID = ?

The order in which you add SqlCeParameter objects to the SqlCeParameterCollection must correspond directly to the position of the question mark placeholder for the parameter.

The data provider for SQL Server CE also does not support batch queries. Commands must follow the following form: SELECT * FROM Customers and not SELECT * FROM Customers; SELECT *

FROM Orders. If you are using code generated for System.Data.SqlClient, you may have to modify your queries to conform to this restriction.

Requirements

Platforms: .NET Compact Framework

.NET Framework Security:

See Also

SqlCeCommand Class | SqlCeCommand Members | System.Data.SqlServerCe Namespace | Connection | CommandType

Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.

Send comments on this topic.

© Microsoft Corporation. All rights reserved.