VB Migration Partner

KNOWLEDGE BASE - Database and data-binding


Previous | Index | Next 

[PRB] Code that references a VB6DataGrid column by its string key may not work in the migrated VB.NET program

Columns in a VB6 DataGrid control can be referenced by either their numeric index or their string key. (The string key is equal to the column’s Caption property.)

This mechanism works correctly with the VB6DataGrid control in converted VB.NET programs. However, we have noticed that assigning a reference to an ADO Data control to the DataSource property causes the control to recreat the Columns collection so that their captions match the fields’ names exactly. (The same thing happens when you assign a DataEnvironment object or an ADO Recordset.)

For this reason, if the VB6 application uses column captions that are different from field names – as it is often the case – then indexing the Columns collection by a string key can’t work correctly after the migration to VB.NET. The simplest workaround for this issue is to manually restore columns’ caption (and therefore, column keys) in the Form_Load event handler, as in this code:

    DataGrid1.Columns(0).Caption = "Supplier"   ' instead of "SupplierID"
    DataGrid1.Columns(1).Caption = "Category"   ' instead of "Category"
Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers