SqlCommand.CommandTimeout seems to have no effect

C

Chris Miller

Hi,

I am trying to set the CommandTimeout property in the .NET SqlCommand object
to less than the default 30 secs. I might also want it to be more than 30
secs. Running a query results in the query not terminating as expected, it
continues until completion.

For example, if I set the CommandTimeout to 5, a query that takes 3 minutes
will complete, which is not expected.

My Sql Server (2000) query timeout is set at 600. I have tried setting this
lower (i.e. 10 sec) but the query will still complete

I was expecting to see an exception (TIMEOUT EXPIRED), but also no exception
is generated.

Does anybody know the rules surrounding this property, for example, does the
sql server always take presedence, is setting less than 30 in the
CommandTimeout valid? (i.e. not 0 for infinite)?

I have seen a lot of conflicting posts about this topic, so if anybody has
come across similar issues or knows how this works, thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top