MySQL Connector/Net
MySqlCommandConnection Property |
Gets or sets the MySqlConnection used by this instance of the
MySqlCommand.
Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.9.9

public MySqlConnection Connection { get; set; }
Public Property Connection As MySqlConnection Get Set
public: property MySqlConnection^ Connection { MySqlConnection^ get (); void set (MySqlConnection^ value); }
member Connection : MySqlConnection with get, set
Property Value
Type: MySqlConnectionThe connection to a data source. The default value is a null reference (Nothing in Visual Basic).

If you set Connection while a transaction is in progress and the Transaction property is not null, an InvalidOperationException is generated. If the Transaction property is not null and the transaction has already been committed or rolled back, Transaction is set to null.

The following example creates a MySqlCommand and sets some of its properties.
public void CreateMySqlCommand() { string mySelectQuery = "SELECT * FROM mytable ORDER BY id"; string myConnectString = "Persist Security Info=False;database=test;server=myServer"; MySqlCommand myCommand = new MySqlCommand(mySelectQuery); myCommand.Connection = new MySqlConnection(myConnectString); myCommand.CommandType = CommandType.Text; }
Public Sub CreateMySqlCommand() Dim mySelectQuery As String = "SELECT * FROM mytable ORDER BY id" Dim myConnectString As String = "Persist Security Info=False;database=test;server=myServer" Dim myCommand As New MySqlCommand(mySelectQuery) myCommand.Connection = New MySqlConnection(myConnectString) 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.
