Link to home
Start Free TrialLog in
Avatar of trigeminus
trigeminus

asked on

CommandTimeout does not work - The timeout period elapsed prior to completion of the operation or the server is not responding

I try to run  time consuming stored procedure, but without success. Execution should take at least a couple minutes.

using (SqlConnection conn = new SqlConnection("Data Source=abc\\sqlexpress;Initial Catalog=DataBase;Integrated Security=True;Connect Timeout=1000"))
                        {
                            SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = 1000;
                            conn.Open();
                            cmd = new SqlCommand("Proc", conn);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@x", SqlDbType.Int).Value = x;
                            cmd.Parameters.Add("@y", SqlDbType.Int).Value = y;
                            cmd.ExecuteNonQuery();
                        }

After a short time appears error message:

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Thanks for any help.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of trigeminus
trigeminus

ASKER

Of course, that's it.