Article ID: 272001 - Last Review: October 16, 2002 - Revision: 1.0

BUG: Attributes Property of ADOX Columns Collection May Cause Append Method to Fail

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q272001

On This Page

Expand all | Collapse all

SYMPTOMS

Attempting to set the Attributes property of a Microsoft ActiveX Data Object (ADOX) Column object to anything other than 0 may cause the Append method of the Tables collection to fail with the following error message:
Run-time error '3265':
Item cannot be found in the collection corresponding to the requested name or ordinal.

CAUSE

This is caused by a bug in the Microsoft ActiveX Data Objects Extensions for Data Definition Language (DDL) and Security, which prevents the setting of the Attributes property of a Column to anything but 0 (where a value of 0 means neither adColFixed nor adColNullable, the two possible values for this property) when other properties of the Column object are also set.

RESOLUTION

If you need to create a nullable or fixed length column, you must create the table through some mechanism other than ADOX, such as DDL SQL statements (CREATE TABLE, for example).

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

The error messages occurs only when you attempt to set one or more properties on a Column object and then also try to set the Attributes property to either adColFixed (1) or adColNullable (2).

Steps to Reproduce Behavior

  1. Create a Standard EXE project in Microsoft Visual Basic. Form1 is created by default.
  2. Set a Project reference to each of the following:
    • Microsoft ADO Ext. 2.x for DDL and Security

    • Microsoft ActiveX Data Objects 2.x Library
  3. Paste the following code into the default Load method of the form:
      Dim conn As New ADODB.Connection
      Dim cat As New ADOX.Catalog
      Dim tbl As New ADOX.Table
      Dim col As String
       
      'The following two lines make a connection to an Access database.
      'Please change the .mdb path as needed. 
      conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "data source=c:\db1.mdb;user id=admin;password=;"
      conn.Open
      cat.ActiveConnection = conn
      Set tbl.ParentCatalog = cat
    
      tbl.Name = "ADOXTab"
      col = "Col1"
      tbl.Columns.Append col, adInteger
    
      tbl.Columns(col).Attributes = adColNullable Or adColFixed
      'Comment out the preceding line and uncomment the next line to make
      'the Append method work.
      'tbl.Columns(col).Attributes = 0
    
      tbl.Columns(col).Properties("Default") = 10
      cat.Tables.Append tbl
    

REFERENCES

For additional information on the limitations of ADOX, click the article numbers below to view the articles in the Microsoft Knowledge Base:
198534  (http://support.microsoft.com/kb/198534/EN-US/ ) ADOX Readme File Included with ADO 2.1 Components
271483  (http://support.microsoft.com/kb/271483/EN-US/ ) Design features of ADOX

APPLIES TO
  • Microsoft ActiveX Data Objects 1.5
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
Keywords: 
kbbug kbcodesnippet kbdatabase kbpending KB272001
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.