BUG: Setting Rst.ActiveConnection to a Recordset Causes GPF

ID: Q193093


The information in this article applies to:
  • Microsoft Data Access Components versions 1.5, 2.0, 2.1 SP2
  • Microsoft Visual Basic Enterprise Edition for Windows, versions 5.0, 6.0


SYMPTOMS

Setting a Recordset's ActiveConnection property to a recordset object causes either a Dr. Watson or a general protection fault (GPF) error to occur. For example:

Set rst.ActiveConnection = rst


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

This problem has been fixed in MDAC version 2.1 Service Pack 2.


MORE INFORMATION

It is not recommended to set the ActiveConnection property to a recordset object. It is recommended that the Recordset's ActiveConnection property be set to an actual Connection object or connection string. The proper behavior is for Visual Basic to respond with a trappable error because ActiveX Data Objects (ADO) is expecting a connection string or object.

Steps to Reproduce Behavior

  1. Open a Standard .exe project in either Visual Basic 5.0 or Visual Basic 6.0.


  2. From the Project menu, choose References, and then select the Microsoft ActiveX Data Objects 2.0 or 1.5 Library.


  3. Paste the following code into the form and enter the correct data source in the ConnectionString parameter of the connection object:


  4. 
          Option Explicit
          Dim cnn As ADODB.Connection
          Dim rst As New ADODB.Recordset
    
          Private Sub Form_Load()
          Set cnn = New ADODB.Connection
          cnn.Provider = "sqloledb"
          cnn.Open "Data Source=<Your Server>;Initial Catalog=pubs;","sa",""
    
          rst.ActiveConnection = rst 'This causes GPF or Dr. Watson error.
          rst.Open "Select * from Authors"
          End Sub 
  5. Run the project.



REFERENCES

For more information on how to correctly open recordsets using ADO, please see the following article in the Microsoft Knowledge Base:

Q168336 HOWTO: Open ADO Connection and Recordset Objects

Additional query words:

Keywords : kbADO150 kbADO200bug kbDatabase kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2fix kbMDAC210SP2
Version : WINDOWS:1.5,2.0,2.1 SP2,5.0,6.0
Platform : WINDOWS
Issue type : kbbug


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