Closes the connection to the database. This is the preferred method of closing any open connection.
Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.8.4.0
Syntax
C# |
public override void Close()
|
Visual Basic |
Public Overrides Sub Close
|
Visual C++ |
public:
virtual void Close() override
|
Implements
IDbConnection..::..Close()()()()
Remarks
Examples
The following example creates a
MySqlConnection, opens it,
displays some of its properties, then closes the connection.
Visual Basic | Copy |
---|
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 |
C# | Copy |
---|
public void CreateMySqlConnection(string myConnString)
{
MySqlConnection myConnection = new MySqlConnection(myConnString);
myConnection.Open();
MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
"\nState: " + myConnection.State.ToString());
myConnection.Close();
} |
See Also