VB Migration Partner

KNOWLEDGE BASE - Database and data-binding

Previous | Index | Next 

[PRB] The data source of a bound control isn’t updated if the control’s value is modified via code

Most databound controls in VB Migration Partner library automatically update their data source when the input focus leaves the control (i.e. in their LostFocus event). However, in general controls don’t update their data source if their value is assigned programmatically.

To help you work around this behavioral difference, the VB6Form and VB6UserControl classes expose a custom UpdateDataSource method, which is meant to be called after a series of assignments to the bound property of a group of controls. The UpdateDataSource method receives an optional argument, i.e. the control whose data source must be updated; if you omit this argument, all the bound controls on the form or usercontrol’s surface are forced to update their data source.

It is convenient to add the call to UpdateDataSource method by means of an InsertStatement pragma:

        Private Sub cmdSave_Click()
            ' copy values from variables to bound controls
            txtName.Text = strName
            txtAddress.Text = strAddress
            txtCity.Text = strCity
            ' in VB6 the data source would be automatically updated, 
            ' whereas in VB.NET it is necessary to force the update
            '## InsertStatement Me.UpdateDataSource()
        End Sub

The VB6Data, VB6RemoteData, and VB6ADODC controls also expose the UpdateDataSource method, which iterates over all the controls that are bound to that specific data control. This method is more convenient if the parent form or usercontrol contains multiple data controls.

        ' Update the data source for all controls bound to the ADODC1 data control
        '## InsertStatement ADODC1.UpdateDataSource()
Previous | Index | Next 

Follow Francesco Balena on VB6 migration’s group on


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.


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