ACC2002: Cannot Use ADOX Views Collection with SQL Server (292791)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q292791
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access project (.adp).

For a Microsoft Access 2000 version of this article, see 225939.

SYMPTOMS

When you try to examine properties of the ADOX Views collection with an Access project that is connected to SQL Server (including SQL Server 2000 Desktop Engine) via the OLE DB Provider for SQL Server (SQLOLEDB), you may receive the following error message:
Error "Run-time error '3251':

Object or provider is not capable of performing requested operation.

CAUSE

The OLE DB Provider for SQL Server does not support the VIEWS schema rowset, which is necessary to provide ActiveX Data Objects (ADO) with information on views that exist in a database that resides on SQL Server.

RESOLUTION

In a Microsoft Access project that is connected to the database that you want to query, use the AllViews collection of the CurrentData property to return basic information about views in your database. There currently is no way to examine remote views via ADO from a Microsoft Access database.

To use the AllViews collection:
  1. Open an Access project that is connected to any SQL Server database.
  2. Create a new module.
  3. On the Tools menu, click References.
  4. Verify that the Microsoft ActiveX Data Objects 2.1 (or later) library is selected.
  5. Close the References dialog box.
  6. Press CTRL+G, and then type the following line in the Immediate window:
    Debug.Print CurrentData.AllViews.Count
    
    						

MORE INFORMATION

Steps to Reproduce the Behavior


  1. Open an Access project that is connected to any SQL Server database.
  2. Create a new module.
  3. On the Tools menu, click References.
  4. Click to select the Microsoft ActiveX Data Objects 2.1 (or later) and the Microsoft ADO Ext. 2.1 (or later) for DDL and Security check boxes.
  5. Close the References dialog box, and then type or paste the following procedure in the newly created module:
    Sub TestCountViews()
        
        Dim cat As New ADOX.Catalog
        Set cat.ActiveConnection = CurrentProject.Connection
    
        Debug.Print cat.Views.Count
    
    End Sub
    						
  6. Run the procedure.

REFERENCES

For more information about the AllViews collection, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type allviews collection in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:11/6/2003
Keywords:AccessCS KbClientServer kbdta kberrmsg kbprb KB292791