Microsoft KB Archive/246919

= FIX: Visual Basic Crashes on Code Generated by ActiveX Control Interface Wizard =

Article ID: 246919

Article Last Modified on 8/7/2007

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q246919



SYMPTOMS
Visual Basic crashes when running a Standard EXE project that contains an ADO Data Control and a UserControl that has DataGrid or MSHFlexGrid controls if the UserControl code was generated by the ActiveX Control Interface Wizard.

The crash occurs on the call to the ReadProperty method of the PropertyBag object in the UserControl's ReadProperties event: Private Sub UserControl_ReadProperties(PropBag As PropertyBag) 'Crashes on the following line: Set DataSource = PropBag.ReadProperty("DataSource", Nothing) End Sub



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0.

For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That a Visual Studio Service Pack Is Installed

To download the latest Visual Studio service pack, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx



Steps to Reproduce Behavior
 In Visual Basic, create a new ActiveX Control project. Project1 is created by default. UserControl1 is added to Project1 by default. From the Project menu, click to select References. From the list of available References, click to select Microsoft Data Source Interfaces. From the Project menu, click to select Components. From the list of available Components, select Microsoft DataGrid Control 6.0 (OLE DB). Add a DataGrid control to UserControl1's Design window. DataGrid1 is added by default. If the ActiveX Control Interface Wizard is not listed on the Add-Ins menu, do the following:  From the Add-Ins menu, select Add-In Manager.</li> From the list of available Add-Ins, select VB6 ActiveX Ctrl Interface Wizard.</li> Check the Loaded/Unloaded checkbox, and then click OK.</li></ol> </li> From the Add-Ins menu, click to select ActiveX Control Interface Wizard. <ol style="list-style-type: lower-alpha;"> At the Introduction screen (if displayed), click Next.</li> At the Select Interface Member dialog box: <ol> Move all pre-selected properties to the list box on the left.Move only the DataSource property to the right, so that it is the only Property listed in Selected names.Click Next.</li> Move only the DataSource property to the right, so that it is the only Property listed in Selected names.Click Next.</li> Click Next.</li></ol>

</li> At the Create Custom Interface Members screen, click Next.</li> In the Maps To section of the Set Mapping screen: <ol> Select DataGrid1 from the Control drop-down list.Select DataSource from the Member drop-down list.Click Next.</li> Select DataSource from the Member drop-down list.Click Next.</li> Click Next.</li></ol>

</li> In the Finished! screen, deselect View Summary Report, and then click Finish.</li></ol> </li> Save and compile the UserControl. Close the UserControl1 Design window.</li> From the File menu, select Add Project to add a Standard EXE project. Project2 is created by default. Form1 is added to Project2 by default.</li> <li>From the Project menu, click to select Components. From the list of available Components, select Microsoft ADO Data Control 6.0 (OLE DB).</li> <li>Place an ADO Data Control onto Form1. ADODC1 is created by default. <ol style="list-style-type: lower-alpha;"> <li>Set the ConnectionString property of the ADO Data Control to connect to the Nwind database that comes with Visual Basic. Connect by using either ODBC or the Jet OLE DB Provider.</li> <li>Set the RecordSource property of the ADO Data Control to the Customers Table.</li></ol> </li> <li>Place an instance of the UserControl onto Form1. UserControl1 is created by default. Set the DataSource property of UserControl1 to ADODC1, the ADO Data Control.</li> <li>In the Project Group in Project Explorer, set Project2 as the Start Up Project.</li> <li> Press function key F8 to Step Into the Project2's code, and note that Visual Basic crashes under the UserControl1_ReadProperties event: Private Sub UserControl_ReadProperties(PropBag As PropertyBag) 'Crashes on the following line: Set DataSource = PropBag.ReadProperty("DataSource", Nothing) End Sub </li></ol>

Additional query words: sp4

Keywords: kbaddin kbbug kbctrl kbdatabase kbdatabinding kbdesigner kbfix kbvs600sp4fix kbvs600sp5fix KB246919

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.