MySQL Connector/Net
MySqlConnectionOpen Method |
Opens a database connection with the property settings specified by the ConnectionString.
Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.9.9

public override void Open()
Public Overrides Sub Open
public: virtual void Open() override
abstract Open : unit -> unit override Open : unit -> unit
Implements
IDbConnectionOpen
Exception | Condition |
---|---|
InvalidOperationException | Cannot open a connection without specifying a data source or server. |
MySqlException | A connection-level error occurred while opening the connection. |

The MySqlConnection draws an open connection from the connection pool if one is available. Otherwise, it establishes a new connection to an instance of MySQL.

The following example creates a MySqlConnection, opens it,
displays some of its properties, then closes the connection.
public void CreateMySqlConnection(string myConnString) { MySqlConnection myConnection = new MySqlConnection(myConnString); myConnection.Open(); MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + "\nState: " + myConnection.State.ToString()); myConnection.Close(); }
Public Sub CreateMySqlConnection(myConnString As String) Dim myConnection As New MySqlConnection(myConnString) myConnection.Open() MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ + ControlChars.Cr + "State: " + myConnection.State.ToString()) myConnection.Close() 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.
