PRB: CommandTimeout Does Not Inherit From Connection Timeout

ID: Q195489


The information in this article applies to:
  • Microsoft Data Access Components versions 1.5, 2.0, 2.1 SP2


SYMPTOMS

If a Connection's CommandTimeout property is set to some value and a Command object is associated to that Connection, the Command object does not pickup the Connection's CommandTimeout setting. Instead, the Command object's CommandTimeout is set to it's default setting or whatever it was set to prior to being associated with the Connection.


CAUSE

ActiveX Data Objects (ADO) does not practice inheritance. Due to the stand alone capability of it's objects, a Command object can be associated with more than one Connection object. The one exception is the CursorLocation property.


RESOLUTION

Specifically set the Command object's CommandTimeout.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a Visual Basic Project.


  2. Set a Project Reference to the Microsoft ActiveX Data Objects Library.


  3. Paste the following code in the Form_Load() event of the default form. You need to modify the connection string so that it references a valid datasouce.


  4. 
          Dim cnn As New ADODB.Connection
          Dim cnstring As String
          cnstring = "Provider = SQLOLEDB;" & _
                     "DATA SOURCE = <data source>;" & _
                     "USER ID = <user id>;" & _
                     "PASSWORD =<password>;" & _
                     "INITIAL CATALOG = <inital catalog>;"
          cnn.CommandTimeout = 0
          cnn.Open cnstring
          Dim cmd As New ADODB.Command
          cmd.ActiveConnection = cnn
          Debug.Print "Timeout on Connection: " & cnn.CommandTimeout
          Debug.Print "Timeout on Command:  " & cmd.CommandTimeout 
  5. Run the form. You should see that the timeout for the command object is set to zero (0) while the connection object is 30 seconds (which is the default).


Additional query words:

Keywords : kbADO150 kbADO200 kbDatabase kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2
Version : WINDOWS:1.5,2.0,2.1 SP2
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: November 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.