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



The information in this article applies to:

  • Microsoft Data Access Components 2.5
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q245341

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 that this is a bug in the Microsoft products that are listed at the beginning of this article.

This problem has been corrected in MDAC 2.5 and later.

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.

Modification Type:MajorLast Reviewed:11/17/2003
Keywords:kbBug kbfix kbMDAC250fix kbMDACNoSweep KB245341