Microsoft KB Archive/201826

= PRB: Error 3265 When You Access Properties Collection =

Article ID: 201826

Article Last Modified on 8/23/2001

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q201826



SYMPTOMS
When you use ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) and try to access properties in the Properties Collection, you may receive the following error message:

Run time error '3265':

ADO could not find the object in the collection corresponding to the

name or ordinal reference requested by the application.

The following error is returned from ADO 2.5 and later:

Run-time error '3265':

Item cannot be found in the collection corresponding to the requested name or ordinal.



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
 Start Visual Basic. Choose the default project type. Set a project reference to each of the following:'''Microsoft ADO Ext. 2.x for DDL and Security and Microsoft ActiveX Data Objects 2.x Library'''.

  Paste the following code into the default form's Load method: 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= " & _ ";USER ID= ;PASSWORD= " & _ ";INITIAL CATALOG= " .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



<div class="references_section">