VBUC
Visual Basic Upgrade Companion. VB6 Converter for .NET & Web.

VB6
ASP
RapidScan-LogoDownload Now

WebMAP
Cloud Application Migration Tools Transform Desktop Applications

C#
Silverlight
Access
VB.NET
PowerBuilder
Winforms
ASP.NET Web Forms

SnowConvert
The best available tools to perform code migrations from a source database or Spark application to Snowflake.

Oracle
Spark Scala
Spark Python
SQL Server
Teradata

Get Started
There are countless ways to take advantage of BlackDiamond Studio and SnowConvert.

Migration and Other Snowflake Services
Get Up and Running with Snowpark
Using the SnowConvert Trial
Build a Cross-Platform Object Inventory

Try BlackDiamond Studio

Time to Mobilize
Free Assessment Tool

VB to .NET

App.Config and Database Access

Table of Contents

Abstract

This document describes the steps necessary to successfully configure the app.config file that is generated by VBUC during the migration of Visual Basic 6.0 data access technologies to ADO.NET using System.Data.Commons.

Description

In .NET Framework 2.0, Microsoft incorporated the System.Data.Common namespace, which contains classes intended to be the base for the implementation of all data providers. This architectural decision allows application designers and programmers to use data provider-agnostic patterns on their data access layers.

VB6 offers several ways to access a database, all of them using COM libraries such as ADO, RDO and DAO. Many of the structures within these packages have their counterpart in the ADO.NET Common architecture, such as Connection and Command; in those cases most of their functionality is covered through our conversion approach.

The most common structure used to retrieve data from the database is the RecordSet object; in the case of ADO and DAO, and Resultset in RDO which are basically a collection of rows retrieved from the data source using a specific SQL command.

As counterpart in the .NET side, we have the DataSet object which also holds data retrieved from the database.

There are differences, though, between the DataSet in .NET and the RecordSet and Resultset.

The most important of them, from a functional equivalence standpoint, is its capability to “remember” the current position and make all data-related operations affect that record. The importance of this feature increases when these kind of object is passed (as parameter) through the different tiers and components of the application.

To accomplish the same functionality in C# .NET, Mobilize has developed Helper classes to handle all these operations. Internally, this class has the necessary infrastructure to support all database requests such as DataAdapters, using the System.Data.Common namespace.

The RDO and ADODB technologies have as well visual controls to interact with the Recordset and Resultset and to bind visual controls to its data. Those controls ADODC and MSRDC are supported as part of the Data access feature to give more functional equivalence to our clients.

Those controls are supported as well via helper implementations and some data binding patterns are supported and automatically upgraded.

Helper Class Design

The Helper classes are based on the specialization inheritance model, where the base class defines all common properties, methods, and the basic functionality. The derived classes overrides, adds new specific behavior to model the details. This design decision gives more functionality without breaking the natural ADO.NET architecture since the Recorset Helper classes are Datasets itself.

This structure is being use on the ADO, RDO, DAO common model as detailed on this diagram:

helper-class-design.jpg

App.config file description

The App.config onfiguration file is an important component in the migration of VB6 legacy data access technologies to ADO.NET using System.Data.Commons. This file contains the list of the providers that the migrated application is capable to use and which are intended to be used as default. It also contains a definition of the columns which values are calculated or retrieved automatically from the database when an insert occurs, such as identities or values set by triggers.

Configuration Section

This tag of the configuration file details the custom configuration section handlers used by the application; in the case of an application converted to ADO.NET using System.Data.Commons, it must be as follows:

complete-configuration-file.png

ConnectionStrings Section

This section specifies the connection strings that will be available for the migrated application.

connections-string.jpg

Factories Configuration Section

This section details the providers that the migrated application may use and which one will be used as Default Provider.

The following data has to be filled out:

  • Name: The name of the provider; this name is the identifier of the provider. If the application needs to use a non-default provider, this is the parameter to be passed to the GetFactory method of the AdoFactorManager class.
  • Factorytype: Is the namespace of the factory to be used.
  • Isdefault: this marks the factory as default. Hence this factory is the one created when the parameter-less GetFactory method is called.
    • Databasetype: this is the type of database that you are trying to interact with; this information is taken by the different recordset helpers to handle many subtle differences between the several database managers. Such as the way to handle the value returned by the database on insertions when there is an identity field involved.

factories-configuration-section.png

In the above example, MS SQL Server provider will be used since its attribute isdefault is set to true.

Identity Columns Configuration Section

This section details the columns that are calculated by the database when an Insert is executed, such as identities or sequence values set by a trigger.

This section has the following data to be filled:

  • Tablename: The name of the table where the column belongs.
  • Columnname: The name of the column
  • Sequencename: This is the name of the sequence where the column name is taken.

ado-identity-columns.png

In the above example, an identity column was configured for table “CR_Customreport”.

Complete Configuration file example

The following is an example of a complete app.config file for a migrated application that can connect to:

  • MS SQLServer using the Microsoft provider. This is the default.
  • Oracle using the ODP provider
  • OleDb Connection.

complete-configuration-file.png

Steps to configure the App.config file in your application

Once the migrated code is generated by the tool, it is necessary to do the following steps to configure the app.config file:

  • Add the app.config file to the Visual Studio solution. To do this, right click on the project name in the Solution Explorer, Click on Add and then “Existing item”. By default, the app.config file is generated on the root folder of the conversion as shown below:

    app-config-picture.jpg

  • Open the app.config and change the configuration according to the database that the migrated application will be using. This includes:

    • Typing the application connection strings under the <connectionStrings> section
    • Setting the isdefault attribute to true for the Factory that the migrated application will use.
  • Save the changes.

Talk To An Engineer