ConnectionTimeout Property

MySQL Connector.Net

Collapse image Expand Image Copy image CopyHover image
Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.

Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.8.4.0

Syntax

C#
public override int ConnectionTimeout { get; }
Visual Basic
Public Overrides ReadOnly Property ConnectionTimeout As Integer
	Get
Visual C++
public:
virtual property int ConnectionTimeout {
	int get () override;
}

Implements

IDbConnection..::..ConnectionTimeout

Remarks

A value of 0 indicates no limit, and should be avoided in a ConnectionString because an attempt to connect will wait indefinitely.

Examples

The following example creates a MySqlConnection and sets some of its properties in the connection string.
Visual Basic Copy imageCopy
Public Sub CreateSqlConnection()
Dim myConnection As New MySqlConnection()
myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"
myConnection.Open()
End Sub
C# Copy imageCopy
public void CreateSqlConnection()
{
MySqlConnection myConnection = new MySqlConnection();
myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";
myConnection.Open();
}

Exceptions

Exception Condition
System..::..ArgumentException The value set is less than 0.

See Also