Not your normal timeout...
-
Here is the error: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. I receive this after ~32 seconds of running a SqlCommand. Now, normally the default timeout is 30 seconds, but I have increased this up to 10 minutes and still the timeout happens in 30 seconds. The connection string says Timeout=600 and I do not override this anywhere in the code. In fact, I can print the timeout prior to running the query and it says 600. Am I missing something obvious here?
-
Here is the error: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. I receive this after ~32 seconds of running a SqlCommand. Now, normally the default timeout is 30 seconds, but I have increased this up to 10 minutes and still the timeout happens in 30 seconds. The connection string says Timeout=600 and I do not override this anywhere in the code. In fact, I can print the timeout prior to running the query and it says 600. Am I missing something obvious here?
-
Here is the error: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. I receive this after ~32 seconds of running a SqlCommand. Now, normally the default timeout is 30 seconds, but I have increased this up to 10 minutes and still the timeout happens in 30 seconds. The connection string says Timeout=600 and I do not override this anywhere in the code. In fact, I can print the timeout prior to running the query and it says 600. Am I missing something obvious here?
-
Also, While declaring the command object set the timeout property 0 i.e. infinity. SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout=0; Try this! :)
Very clever that you reply twice so I can give you two 5's :laugh: Answer is very much appreciated (with small modification)!
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout=con.ConnectionTimeout;Now I can still modify the timeout just from the config file's connection string.
-
Here is the error: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. I receive this after ~32 seconds of running a SqlCommand. Now, normally the default timeout is 30 seconds, but I have increased this up to 10 minutes and still the timeout happens in 30 seconds. The connection string says Timeout=600 and I do not override this anywhere in the code. In fact, I can print the timeout prior to running the query and it says 600. Am I missing something obvious here?
You're setting the timeout on the CONNECTION attempt, not the query execution timeout. You do that in the SqlCommand object you're using to execute your query.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Very clever that you reply twice so I can give you two 5's :laugh: Answer is very much appreciated (with small modification)!
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout=con.ConnectionTimeout;Now I can still modify the timeout just from the config file's connection string.