MySqlCommand.CommandText Property

MySQL Connector/Net

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

Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.9.9
Syntax
public override string CommandText { get; set; }
Public Overrides Property CommandText As String
	Get
	Set
public:
virtual property String^ CommandText {
	String^ get () override;
	void set (String^ value) override;
}
abstract CommandText : string with get, set
override CommandText : string with get, set

Property Value

Type: String
The SQL statement or stored procedure to execute. The default is an empty string.

Implements

IDbCommandCommandText
Remarks

When the CommandType property is set to StoredProcedure, the CommandText 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. Starting with Connector/Net 5.0, having both a stored function and stored procedure with the same name in the same database is not supported. It is suggested that you provide unqiue names for your stored routines.

Examples
The following example creates a MySqlCommand and sets some of its properties.
public void CreateMySqlCommand()
{
MySqlCommand myCommand = new MySqlCommand();
myCommand.CommandText = "SELECT * FROM mytable ORDER BY id";
myCommand.CommandType = CommandType.Text;
}
Public Sub CreateMySqlCommand()
Dim myCommand As New MySqlCommand()
myCommand.CommandText = "SELECT * FROM Mytable ORDER BY id"
myCommand.CommandType = CommandType.Text
End Sub

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also