I've got a lengthy running SQL statement that I wish to run, and regardless of what I make the "timeout=" clause of my connection string, it always appears to finish after thirty seconds. I am simply using SqlHelper.ExecuteNonQuery() to complete it, and allowing it to take proper care of opening connections, etc.
Can there be another thing that may be overriding my timeout, or leading to sql server to disregard it? I've run profiler within the query, and also the trace does not look different after i run it in management studio, versus during my code.
Management studio completes the query in roughly one minute, but despite a timeout set to 300, or 30000, my code still occasions out after thirty seconds.
What exactly are you using to create the timeout inside your connection string? From memory that's "ConnectionTimeout" and just affects time it requires to really connect towards the server.
Every individual command includes a separate "CommandTimeout" which may be what you are searching for. Unsure how SqlHelper implements that though.
Additionally to timeout in connection string, use the timeout property from the SQL command. Below is really a C# sample, while using SqlCommand class. Its equivalent ought to be relevant to what you're using.
SqlCommand command = new SqlCommand(sqlQuery, _Database.Connection); command.CommandTimeout = 0; int rows = command.ExecuteNonQuery();
Thanks both. Setting CommandTimeout reduced the problem. We now have the issue of re-engineering our ORM to reveal that property :)
Its a little strange though, as altering for that connection timeout, i am sure has labored before, for several lengthy-running chooses and saved methods. Based on what you're saying, which should have very little affect.