VB6 Database code?

What happens when you upgrade a VB6 application that accesses a database? Or, more precisely, how does the automatic upgrade deal with DAO, RDO and ADO?

  • ADO with and without data binding. This is supported by the upgrade wizard, but if you’ve got any dynamic data binding code you’ll need to fix some issues.
  • Upgrading DAO and RDO code that DOES NOT use any Data Binding. This scenario is straightforward. The code is upgraded and still uses the old libraries. VB6 syntax like this:

Dim rstExample As Recordset
Dim strExample As String
strExample = rstExample!Author

is converted to this:

Dim rstExample As DAO.Recordset
Dim strExample As String
strExample = rstExample.Fields("Author").Value

  • Upgrading DAO and RDO code that DOES use Data Binding. The upgrade wizard doesn’t support upgrading data binding (it appears to upgrade the RDO control, but you’ll find it doesn’t actually work at runtime). So the recommendation is to manually upgrade your RDO and DAO to ADO data binding, and then run the upgrade wizard.

The ADO upgrade doesn’t upgrade to ADO.NET, it creates wrapper code that lets your VB.NET call the ADO COM libraries. One consequence of this is that the ADO data binding is not exposed at design time in Visual Studio, you have to go to the code. A similar approach is taken with Data Environments – they are upgraded, but only as code so they can no longer be edited visually.

ADO.NET, datasets, LINQ and ADO.NET data binding will all count as “Application Advancements” (see my earlier post “Functional Equivalence and Application Advancement”).