Determines whether connection to MySQL server is valid.
[Visual Basic]
Public Function Ping() As Boolean [C#]
public bool Ping();true, if the connection is valid; otherwise, false.
If the application has an open connection for a long time, it is recommended to check a connection for validation before using it. Call of Ping method has single round trip on MySQL server.
It is not a good idea to keep a connection open for long time. Connection pool automatically pings all connections within, thus closing old connections and opening new ones is encouraged.
This code sample shows how to check for server availability before issuing a query.
[C#]
public void ExecuteSafely(MySqlConnection myConnection) |
[Visual Basic]
Public Sub ExecuteSafely(ByVal myConnection As MySqlConnection) |
MySqlConnection Class | MySqlConnection Members
© 2002 - 2008 Devart. All Rights Reserved.