VB Migration Partner

KNOWLEDGE BASE - Database and data-binding

Previous | Index | Next 

[INFO] Converted DataEnvironment instances open the connection only when needed

There is a minor difference between VB6 DataEnvironment classes and migrated VB6DataEnvironment .NET classes. The original VB6 DataEnvironment class opens all its ADODB connection as soon as it is instantiated; the migrated VB6DataEnvironment class opens the connection only when a command is actually executed.

In the majority cases, this difference doesn’t cause any problem and slightly improve overall performance. However, you must keep this detail into accout if you want to share the DataEnvironment’s connection with other ADODB object or you want to manually execute one of the DataEnvironment’s commands. Consider the following code:

  ' take a reference to a command exposed by the DataEnvironment
  Dim adoCmd As ADODB.Command 
  Set adoCmd = deCRM.Commands("cmdCustomers")
  ' manually execute it

The above code works fine under VB6, because the Command object extracted from the DataEnvironment is associated with an open connection, but fails when the code is migrated to .NET, because no open connection has been associated yet with the Command object. You can account for this difference by opening the connection and associating it to the Command yourself, as shown in this piece of VB.NET code:

  ' take a reference to a command exposed by the DataEnvironment
  Dim adoCmd As ADODB.Command = deCRM.Commands("cmdCustomers")
  ' open the connection associated with the Data Environment
  ' associate the connection with the command
  adoCmd.ActiveConnection = deCRM_DefInstance.datNwind
  ' manually execute it
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