Connection Property (MySqlCommand)
Gets or sets the
MySqlConnection used by this instance of the
MySqlCommand.
Property Value
The connection to a data source. The default value is a null reference.
The following example creates a
MySqlCommand and sets some of its properties.
public void CreateCommand()
{
string mySelectQuery = "SELECT * FROM Test.Dept ORDER BY DeptNo";
MySqlCommand myCommand = new MySqlCommand(mySelectQuery);
myCommand.Connection = new MySqlConnection(
"User Id=root;Host=localhost;Database=Test;");
myCommand.CommandType = System.Data.CommandType.Text;
}
Public Sub CreateCommand()
Dim mySelectQuery As String = _
"SELECT * FROM Test.Dept ORDER BY DeptNo"
Dim myCommand As New MySqlCommand(mySelectQuery)
myCommand.Connection = New MySqlConnection( _
"User Id=root;Host=localhost;Database=Test;")
myCommand.CommandType = System.Data.CommandType.Text
End Sub