13

I am gettting SQL time out error in my .net service.

As the service is already installed on the production, is there any way I can increase the timeout for the service from App.Config file.

At present, I am getting this exception after one minute, I have to make it to around 10 hours because the stored procedure we are using takes 2-2 hours to execute.

Zerotoinfinity
  • 6,290
  • 32
  • 130
  • 206

3 Answers3

17

You could try setting the CommandTimeout property on your SqlCommand. I hope you are not doing this in an ASP.NET application.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
1

The time out setting is up to database server.

In SQL Server Manager open the SQL Server Properties and pick the connection tab and set time out as big as You need.

Ps.

zero goes for no timeout.

  • Thanks Vash. But I am getting .NET exception. If I am running the same stored procedure in SQL Server Managaement studio, it is allowing me to run that for the number of hours I want. – Zerotoinfinity Oct 21 '10 at 08:55
  • There is a timeout on the database server and there is a separate timeout on .net. Which ever is shorter is what will actually limit your run time. – Jason Cheng Aug 23 '19 at 18:27
1

You can set the timeout in your connection string with "connect Timeout = 100000000;" or whatever you want your timeout to be

Statler
  • 324
  • 1
  • 3
  • 7
  • Can I put connection timeout in App.Config file? – Zerotoinfinity Oct 21 '10 at 08:54
  • 1
    No, you can't. This will have absolutely no effect. Command Timeout in connection string is ignored. – Darin Dimitrov Oct 21 '10 at 08:55
  • 1
    It works for me. You put it in your connection string, which is p in app.config or web.config if you set it up through a visual studio tool – Statler Oct 21 '10 at 09:16
  • 3
    Darin is right. `Connect Timeout=1234` can be set in app.config. But that is just for *connections*. But the timeout for queries is controlled by command timeout which can *not* be set in app.config. – Björn Lindqvist Jun 18 '13 at 08:49
  • This is useless. The connect timeout is different than the command timeout. The connect timeout is only used to establish the connection, not to run queries. – Jason Cheng Aug 23 '19 at 18:26