SqlCommand.CommandTimeout seems to have no effect

  • Thread starter Thread starter Chris Miller
  • Start date Start date
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
 
Back
Top