|
| MySQL Connector/Net |
| MySqlCommand Constructor (String) |
| MySqlCommand Class Example See Also Send Feedback |
|
Initializes a new instance of the MySqlCommand class with the text of the query.
Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.8.4.0
Syntax
| C# |
|---|
public MySqlCommand( string cmdText ) |
| Visual Basic |
|---|
Public Sub New ( _ cmdText As String _ ) |
| Visual C++ |
|---|
public: MySqlCommand( String^ cmdText ) |
Parameters
- cmdText
- Type: System..::..String
The text of the query.
Remarks
When an instance of MySqlCommand is created,
the following read/write properties are set to initial values.
| Properties | Initial Value |
|---|---|
| CommandText | cmdText |
| CommandTimeout | 0 |
| CommandType | CommandType.Text |
| Connection | Null |
You can change the value for any of these properties through a separate call to the property.
Examples
The following example creates a MySqlCommand and
sets some of its properties.
| Visual Basic | Copy |
|---|---|
Public Sub CreateMySqlCommand() Dim sql as String = "SELECT * FROM mytable" Dim myCommand As New MySqlCommand(sql) myCommand.CommandType = CommandType.Text End Sub | |
| C# | Copy |
|---|---|
public void CreateMySqlCommand() { string sql = "SELECT * FROM mytable"; MySqlCommand myCommand = new MySqlCommand(sql); myCommand.CommandType = CommandType.Text; } | |