MySQL query timeout
I'm trying to execute a query using C#. The problem is that, despite开发者_如何学编程 the fact that I modified the timeout period, it thrown a timeout exception. It is rising the exception after 30 seconds, that is the default value.
using (MySqlConnection conn = new MySqlConnection(connStr))
{
int x = conn.ConnectionTimeout;
conn.Open();
cmd.Connection = conn;
cmd.CommandText = "SELECT AVG(v.value_min) AS minValue FROM values v";
adpter.SelectCommand = cmd;
adpter.Fill(dados);
conn.Close();
}
As you can see, I'm using conn.ConnectionTimeout
to check if the timeout is properly configured and, yes it is. At least it shows the amount of time that I configured (in that case 90).
So, how do I do this? How to run a long time query?
UPDATE: The query that I posted is just an example.
Setting the CommandTimeout
property on your MySqlCommand
instead of the connection should do the trick.
精彩评论