System.Data.OleDb.OleDbCommand.CommandText Property

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

Syntax

[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)]
[System.ComponentModel.Editor("Microsoft.VSDesigner.Data.ADO.Design.OleDbCommandTextEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultValue("")]
public override string CommandText { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

When the OleDbCommand.CommandType property is set to StoredProcedure, the OleDbCommand.CommandType property should be set to the name of the stored procedure. The user may be required to use escape character syntax if the stored procedure name contains any special characters. The command executes this stored procedure when you call one of the Execute methods.

When OleDbCommand.CommandType is set to TableDirect, the OleDbCommand.CommandType property should be set to the name of the table or tables to be accessed. The user may be required to use escape character syntax if any of the named tables 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 OleDbCommand.Connection, OleDbCommand.CommandType, and OleDbCommand.CommandText properties if the current connection is performing an execute or fetch operation.

The OLE DB.NET Provider does not support named parameters for passing parameters to an SQL Statement or a stored procedure called by an System.Data.OleDb.OleDbCommand when OleDbCommand.CommandType is set to Text. In this case, the question mark (?) placeholder must be used. For example:

SELECT * FROM Customers WHERE CustomerID = ?

Therefore, the order in which System.Data.OleDb.OleDbParameter objects are added to the System.Data.OleDb.OleDbParameterCollection must directly correspond to the position of the question mark placeholder for the parameter.

For more information, see Using Stored Procedures with a Command.

Requirements

Namespace: System.Data.OleDb
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0