FIX: Visual Basic Crashes When Appending a New Column to an Existing Table

ID: Q245341


The information in this article applies to:
  • Microsoft Data Access Components version 2.5
  • Microsoft Visual Basic Professional and Enterprise Editions, 32-bit only, for Windows, version 6.0


SYMPTOMS

Microsoft Visual Basic crashes when appending a newly-created column to a table by setting the ParentCatalog property of a column to an active catalog and adding it to an existing table.


STATUS

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

This problem has been corrected in MDAC 2.5.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new Standard EXE project in Visual Basic. Form1 is created by default. Reference either the Microsoft ADO Ext. 2.5 for DDL and Security object library, or the Microsoft ADO Ext. 2.1 for DDL and Security object library.


  2. On the Tools menu, select Options. On the General tab, make sure you do not have Break on All Errors selected.


  3. Double-click Form1. Copy and paste the following code in the Form_Load() event:
    
    Private Sub Form_Load()
        Dim cat As New ADOX.Catalog
        Dim col1 As New ADOX.Column
        Dim col2 As New ADOX.Column
        Dim tbl As New ADOX.Table
        
        cat.ActiveConnection = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb"
        On Error Resume Next
        cat.Tables.Delete "Table1"
        On Error GoTo 0
        tbl.Name = "Table1"
        tbl.Columns.Append "Column1", adSmallInt
        
        cat.Tables.Append tbl
        
        col1.Name = "Column2"
        col1.ParentCatalog = cat
        col1.Properties.Refresh
        cat.Tables("Table1").Columns.Append col1    'VB crashed here
    End Sub 
    Modify the Data Source path to point to a valid .mdb file.


  4. Save and run the project. If you are using ADO 2.5, then the project completes successfully. If you are using ADO 2.1, then the application terminates abnormally.


Additional query words:

Keywords : kbVBp600bug kbGrpVBDB kbGrpMDAC kbDSupport kbMDAC250fix
Version : WINDOWS:2.5,6.0
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: February 1, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.