0

I got the error

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

during the command execution.

I also set Connect Timeout=60 in the connection string.

That stored procedure execution time is around 35 seconds.

Connection is established, but result is not returned.

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
  • 1
    https://stackoverflow.com/questions/847264/what-is-the-difference-between-sqlcommand-commandtimeout-and-sqlconnection-conne – Sarvesh Mishra Feb 08 '19 at 06:16
  • 1
    Possible duplicate of [What is the difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout?](https://stackoverflow.com/questions/847264/what-is-the-difference-between-sqlcommand-commandtimeout-and-sqlconnection-conne) – Stefan Becker Feb 08 '19 at 06:24
  • Have you thought whether it is possible to optimise your stored procedure? – Steve Ford Feb 08 '19 at 09:20

2 Answers2

5

DbCommand has CommandTimeout, which is what you want here - it is set per command; the "connect timeout" only impacts, reasonably enough, what the timeout is for connecting. The default value for CommandTimeout on SqlCommand is 30 seconds.

Marc Gravell
  • 976,458
  • 251
  • 2,474
  • 2,830
1

You can also extend connection timeout in connectionstring

;Connection Timeout=30

See: Connection timeout for SQL server

VoonArt
  • 876
  • 1
  • 7
  • 21