Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q245341

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB245341, kbmdacnosweep, kbmdac250fix, kbfix, kbbug

↑ Back to the top

Article Info
Article ID : 245341
Revision : 3
Created on : 11/17/2003
Published on : 11/17/2003
Exists online : False
Views : 312