Re: SqlCommand.CommandTimeout seems to have no effect

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Here's a link to the documentation -- does this help?

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

--Mary

On Fri, 10 Oct 2008 06:22:00 -0700, Chris Miller
<ChrisMiller@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

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


.



Relevant Pages

  • SqlCommand.CommandTimeout seems to have no effect
    ... I am trying to set the CommandTimeout property in the .NET SqlCommand object ... Running a query results in the query not terminating as expected, ... I was expecting to see an exception, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: timeout error
    ... You can set the CommandTimeout property of the ADO Command or Connection ... depending on which you are using to execute the query. ...
    (microsoft.public.sqlserver.server)
  • Re: Terminating a long query... the Recordset.Cancel method does not w
    ... I seem to recall the older Oracle providers did not support commandtimeout. ... > CANCEL method also does not stop the query. ... As soon as the CANCEL ...
    (microsoft.public.data.ado)
  • Re: Timeout on populating a datagrid
    ... The CommandTimeout property of an OleDbCommand object defaults to 30 ... be to bump the CommandTimeout property up to a number where the query ... >> stored procedure you use to update a record in the database. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: SQL Timeout Error
    ... I am not sure what you mean by "to clarify how you actually ran it" (sorry I ... created a View (just like creating a Select query). ... how or where do I set the CommandTimeout? ... error message: timeout expired. ...
    (microsoft.public.sqlserver.server)