Microsoft Knowledge Base Email Alertz

(175264) - The Connection object of the ActiveX Data Objects supports the CommandTimeout property. This property is documented to support a value of 0, which provides for an infinite timeout. This functionality is not available in ActiveX Data Objects 1.0.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 175264 - Last Review: May 2, 2006 - Revision: 3.1

FIX: CommandTimout Property Problem with Connection Object

This article was previously published under Q175264

SYMPTOMS

The Connection object of the ActiveX Data Objects supports the CommandTimeout property. This property is documented to support a value of 0, which provides for an infinite timeout. This functionality is not available in ActiveX Data Objects 1.0.

RESOLUTION

The CommandTimeout property functions properly for all values other than 0. If you wish an infinite timeout, you will need to use this parameter in conjunction with the Command object instead. The following example demonstrates how to set the Command object's timeout:
   Set MyConn = Server.CreateObject("ADODB.Connection")
   MyConn.ConnectionTimeout = 0
   MyConn.CommandTimeout = 0 ' *** THIS HAS
    *** NO EFFECT BECAUSE OF THE BUG ***
   MyConn.Open ConStr, UserId, PassWord
  
   Set cmdTemp = Server.CreateObject("ADODB.Command")

   ' *** T H I S   L I N E   W A S   A D D E D ***
   cmdTemp.CommandTimeout = 0 ' *** SETTING IT TO ZERO CAUSES IT TO WAIT
    FOREVER ***
				

NOTE: The CommandTimeout property on an ADO connection object has no effect on the CommandTimeout property setting of the command object on the same connection. Essentially, the command object's CommandTimeout property does not inherit the value of the connection object's CommandTimeout value.

In order for cmdTemp.CommandTimeout = 0 to work properly, you must use the command object to execute the query.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in MDAC 2.6.

MORE INFORMATION

The following code attempts to set the timeout to 0. When set to this value, the connection object should provide for an indefinite amount of time before timing out. It does not.
   <%
   Set cn = Server.CreateObject("ADODB.Connection")
   cn.CommandTimeout = 0
   cn.Open "datasourcename", "userid", "password"
   cn.Execute("SQL statement that would cause a timeout")
   %>
				

REFERENCES

For the latest Knowledge Base articles and other support information on Visual InterDev and Active Server Pages, see the following page on the Microsoft Technical Support site:
http://support.microsoft.com/search/default.aspx?qu=vinterdev (http://support.microsoft.com/search/default.aspx?qu=vinterdev)


APPLIES TO
  • Microsoft Active Server Pages 4.0
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft Data Access Components 2.5
Keywords: 
kbado260fix kbaspobj kbbug kbcodesnippet kbdatabase kbfix kbmdac260fix kbmdacnosweep KB175264
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate