BUG: Upgrade Wizard incorrectly converts an ActiveX control's DataSource property when you upgrade a project from Visual Basic 6.0 to Visual Basic 2005 or to Visual Basic .NET (316170)



The information in this article applies to:

  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

This article was previously published under Q316170

SYMPTOMS

When you use the Upgrade Wizard to upgrade a project from Microsoft Visual Basic 6.0 to Microsoft Visual Basic 2005 or to Microsoft Visual Basic .NET, the DataSource property of the ActiveX controls contained in the upgraded project may not migrate correctly. If the fully qualified name is used to access the DataSource property, the DefInstance property is not added during migration.
For example, the following line of code appears in your Visual Basic 6.0 project.
Set Form1.DataGrid1.DataSource = Form1.Adodc1
				
After the upgrade to Visual Studio 2005 or to Visual Studio .NET, this line appears as follows.
'UPGRADE_ISSUE: VBControlExtender property DataGrid1.DataSource is not supported at runtime.
Click for more: ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2066"
Set Form1.DataGrid1.DataSource = Form1.DefInstance.Adodc1
				
The "Form1.DataGrid1" element is underlined by the blue, wiggly line that is used for error alerts.

Note If you replace "DataGrid1" with any Visual Basic 6.0 ActiveX control that supports the DataSource property, this should still throw the same error.

CAUSE

This behavior occurs because the Upgrade Wizard does not properly handle the DataSource property of the ActiveX controls that support this property.

RESOLUTION

To resolve this issue, manually add DefInstance between the form name and the ActiveX control name: Specifically, change Form1.DataGrid1 to Form1.DefInstance.DataGrid1.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Note The Visual Basic 2005 or Visual Basic .NET Upgrade Wizard is included with Visual Studio 2005 and with Visual Studio .NET Professional Edition.

Steps to reproduce the problem

  1. Start Visual Basic 6.0, and then open a new Standard EXE project.

    Form1 is added by default.
  2. Add a .bas module to the project.
  3. Add the Microsoft ADO Data Control 6.0 (OLEDB) and Microsoft DataGrid Control 6.0 (OLEDB) controls to Form1.
  4. Add the following code to the .bas module.
    Sub Main()
      Form1.Show
      Set Form1.DataGrid1.DataSource = Form1.Adodc1
    End Sub
    						
    Make sure that the names of the objects in this code match the name of the objects that you placed on the form in step 3.
  5. Make Sub Main the startup object for the project.
  6. Save the project, and then quit Visual Basic 6.0.
  7. Start Visual Studio 2005 or Visual Studio .NET, and then open the project that you saved in step 6.

    This starts the Upgrade Wizard.
  8. Navigate through the Upgrade Wizard and accept all of the defaults.
  9. After the Upgrade Wizard is finished upgrading the project, open the module.

    The code will now look like the following.
    Public Sub Main()
       Form1.DefInstance.Show()
       'UPGRADE_ISSUE: VBControlExtender property DataGrid1.DataSource is not supported at runtime. Click for more: ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2066"
       Form1.DataGrid1.DataSource = Form1.DefInstance.Adodc1
    End Sub
    						
    "Form1.DataGrid1" is underlined by the blue, wiggly error line.

Modification Type:MinorLast Reviewed:10/3/2006
Keywords:kbvs2005applies kbvs2005swept kbvs2002sp1sweep kbmigrate kbbug KB316170 kbAudDeveloper