MySqlCommand Constructor (String, MySqlConnection)

MySQL Connector/Net

MySqlCommand Constructor (String, MySqlConnection)
Initializes a new instance of the MySqlCommand class with the text of the query and a MySqlConnection.

Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.9.9
Syntax
public MySqlCommand(
	string cmdText,
	MySqlConnection connection
)
Public Sub New ( 
	cmdText As String,
	connection As MySqlConnection
)
public:
MySqlCommand(
	String^ cmdText, 
	MySqlConnection^ connection
)
new : 
        cmdText : string * 
        connection : MySqlConnection -> MySqlCommand

Parameters

cmdText
Type: SystemString
The text of the query.
connection
Type: MySql.Data.MySqlClientMySqlConnection
A MySqlConnection that represents the connection to an instance of SQL Server.
Remarks
When an instance of MySqlCommand is created, the following read/write properties are set to initial values.
PropertiesInitial Value
CommandTextcmdText
CommandTimeout0
CommandTypeCommandType.Text
Connectionconnection

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.
public void CreateMySqlCommand()
{
MySqlConnection conn = new MySqlConnection("server=myserver")
string sql = "SELECT * FROM mytable";
MySqlCommand myCommand = new MySqlCommand(sql, conn);
myCommand.CommandType = CommandType.Text;
}
Public Sub CreateMySqlCommand()
Dim conn as new MySqlConnection("server=myServer")
Dim sql as String = "SELECT * FROM mytable"
Dim myCommand As New MySqlCommand(sql, conn)
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