MySQL Connector/Net |
MySqlConnection..::.ConnectionTimeout Property |
MySqlConnection Class Example See Also Send Feedback |
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.2.2.0
Syntax
C# |
---|
public override int ConnectionTimeout { get; } |
Visual Basic (Declaration) |
---|
Public Overrides ReadOnly Property ConnectionTimeout As Integer |
Visual C++ |
---|
public: virtual property int ConnectionTimeout { int get () override; } |
Implements
IDbConnection..::.ConnectionTimeoutRemarks
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.
CopyVB.NET
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
CopyC#
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. |