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,
Tap
tapanan2519Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PedroCGDCommented:
Dear friend,
I reseolved a similar problem installing cmulative package 7 (after SQL SP2) that fixes several bugs:
http://support.microsoft.com/kb/949095
Helped?
Regards!
Pedro
www.pedrocgd.blogspot.com
0
tapanan2519Author 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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.