SQL timeout expired in C# code

808 views Asked by At

I'm working in a new C# project and need some help.

The system has some jobs scheduled using Quartz api and one them is not working anymore.

I try to execute the method manually and got this error

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

in this line (the catch{} is called):

TList<TbBooking> allBooks = DataRepository.TbBookingProvider.Find(bQuery);

the variable bQuery has a query with 4200 id's and some parameters like 1 month period, flags etc.

I checked the SQL Timeout settings and it's 10 min (default) but the message appears in few seconds after the code enter in the .Find() method (less than 2 minutes) but using the SQLMS the query is executed pretty quick.

I'm thinking about run the command sp_updatestats but I wanna see your suggestions first.

p.s. The project is using codesmith and this funcionality was working since 2010.

1

There are 1 answers

0
Leandro Brito On

I used the sp_updatestats and it didn't work. I create a index for the column and didn't work too. So I found a propertie in ProviderBase class named defaultCommandTimeout set to 30 seconds. I change it in my app.config file to 120 and the query worked again.