PRB: Error 3265 When Accessing Properties Collection

ID: Q201826


The information in this article applies to:
  • ActiveX Data Objects (ADO), version 2.1


SYMPTOMS

When using ADOX and attempting to access properties in the Properties Collection, the following error might occur:

Run time error '3265':
ADO could not find the object in the collection corresponding to the
name or ordinal reference requested by the application.


CAUSE

The object's ParentCatalog property was not set to a valid Catalog object,

-or-

the ADO Connection object associated with the Parent Catalog may be invalid.


RESOLUTION

Set the object's ParentCatalog property to a valid Catalog object,

-or-

make sure the Parent Catalog is associated with a valid ADO Connection Object.


STATUS

This behavior is by design.


MORE INFORMATION

The Properties collection associated with ADOX objects exposes provider-specific properties. However, ADOX objects can not expose this collection if there is not a channel for ADOX to talk to the Provider. This channel is created through the object's ParentCatalog property that points to a Catalog object. The Catalog object's Connection property must be set to a valid, opened ADO Connection object. Once this is in place, ADOX objects can expose any exposed provider-specific properties.

Steps to Reproduce Behavior

  1. Start Visual Basic.


  2. Choose the default project type.


  3. Set a project reference to each of the following:


  4. Microsoft ADO Ext. 2.1 for DDL and Security and Microsoft ActiveX Data Objects 2.1 Library.

  5. Paste the following code into the default form's Load method:


  6. 
       Dim cnn As ADODB.Connection
       Dim cat As ADOX.Catalog
       Dim tbl As ADOX.Table
       Dim col As ADOX.Column
       Dim idx As ADOX.Index
    
       Set cnn = CreateObject("ADODB.Connection")
    
       With cnn
          .ConnectionString = "PROVIDER=SQLOLEDB" & _
                              ";DATA SOURCE=<server name>" & _
                              ";USER ID=<uid>;PASSWORD=<pwd>" & _
                              ";INITIAL CATALOG=<catalog name>"
          .Open
       End With
    
       Set cat = CreateObject("ADOX.Catalog")
       cat.ActiveConnection = cnn
    
       Set tbl = CreateObject("ADOX.Table")
       tbl.Name = "test"
    
       tbl.Columns.Append "iMyID", adInteger
       tbl.Columns.Append "cTest", adChar, 15
    
       ' Comment the Line below and
       ' Uncomment the duplicate line two lines below to avoid error.
       tbl.Columns(0).Properties("Autoincrement").Value = True
       'This line is the key.
       Set tbl.ParentCatalog = cat
       'tbl.Columns(0).Properties("Autoincrement").Value = True
       cat.Tables.Append tbl
     


REFERENCES

The following is from Help under the ParentCatalog Property from the Data Acces Software Development Kit for use with Microsoft Data Access Components:

Some data providers allow provider-specific property values to be written only at creation (when a table or column is appended to its Catalog collection). To access these properties before appending these objects to a Catalog, specify the Catalog in the ParentCatalog property first.

Additional query words:

Keywords : kbADO kbADO210 kbDatabase kbGrpVBDB kbGrpMDAC
Version : WINDOWS:2.1
Platform : WINDOWS
Issue type : kbprb


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