Reputation: 3364
I want to increase the connection timeout for mysql connection and I can not modify the timeout settings from administrator panel of mysql server. I want to do it within c# application and I noticed that I can read the property ConnectionTimeout of MySqlConnection class. I would like to know that is there a way to increase the connection time before opening mysql connection.
Upvotes: 8
Views: 47939
Reputation: 504
default command timeout=0 in your connection string does the trick.
String connectionString = "Server=myserver; Port=3306; Database=databasename; Uid=userid; Pwd=password;default command timeout=0";
Upvotes: 1
Reputation: 85
use "default command timeout" in your connection string, it works for me
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
default command timeout=20;
Upvotes: 7
Reputation: 4638
Check out the wait_timeout parameter for my.ini
Here is the link. restart mysql after changing the value.Why, because There may be multiple my.ini's on your system - make sure you're changing the right one
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_wait_timeout
or
you can define in your connection string
String myconnstring = "Server=yourservername; Port=portno; Database=yourdatabasename; Uid=yourUSERID; Pwd=yourpassword;Connection Timeout=120";
Upvotes: 3
Reputation: 26209
you can change ConnectionString
as below:
String connectionString = "Server=myserver; Port=3306; Database=databasename; Uid=userid; Pwd=password;Connection Timeout=30";
in the above Connection String
you can specify the number of seconds as value for Connection Timeout
Upvotes: 18