Timeout Expired Error When Running Long Query and Large Database

I have been getting the infamous 'Timeout Expired' problem with my web application developed using MS .NET and using Microsoft SQL Server 2005. The query is long and the database contains over 800K records further linked with some other tables. The query worked fine when the database contained about 500-600K records (we have a backup of the old database). On 500-600K records, the query takes less than a minute to complete.

Now, I've been browsing the internet for solutions and we did try them. These are:
1. Changing SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout to 0.
2. Adding 'with (nolock)' to the query.

However, neither of them work. I am in desperate needs for help. Thank you in advance.

Best regards,
Who is Participating?
tapanan2519Connect With a Mentor Author Commented:
I have found that the problem is with using SqlAdapter. After setting timeout = 0 for the SqlCommand object, I use it to construct a SqlAdapter object, where it seems the timeout value was not passed to it. So basically, I had to set timeout=0 on the SqlAdapter object, rather than the original of SqlCommand.
Dear friend,
I reseolved a similar problem installing cmulative package 7 (after SQL SP2) that fixes several bugs:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.