How To increase SQL CommandTimeout in C# more than 10 hours

Question

Saturday, May 25, 2013 9:44 AM

Hi All,

I am running a store procedure using C#. That store procedure will take more than 10 hours to complete because of huge volume of data.

If run the store procedure directly I am getting the result after 10 hours.

But If run the same Store procedure using c# I am getting Timeout error after 9 hrs.

When I cross checked.

SQL CommandTimeout will take only integer value and its maximum value is 32767 which is equal to 9 hours.

Could  any one please tell how can increase Timeout more than 10 hrs.

Thanks in advance.

Regards,

Vishnu

All replies (2)

Saturday, May 25, 2013 10:17 AM âś…Answered

Hi Vishnu,

setting SqlCommand.CommandTimeout to 0 the command will wait indefinitely.

A better solution could be using a SQL Agent job for such a long running procedure.

Regards, Elmar


Saturday, May 25, 2013 5:19 PM

Hi Elmar,

Thanks your reply has answered my question.

Thanks a lot :)

Regards,

Vishnu,