1

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.

1 Answer 1

2

Setting the CommandTimeout property on your MySqlCommand instead of the connection should do the trick.

Sign up to request clarification or add additional context in comments.

1 Comment

Opps... Thanks. I dind't saw the property,,,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.