DAO to Data.Common with helpers

    Related Content

    The VBUC upgrades the DAO data access technology to ADO.NET ONLY by means of the System.Data.Common namespace. If the original VB6 code contains DAO code the VBUC will upgrade the data access code following the next transformation table:

    Class Maps to
    DAO.Recordset Artinsoft.VB6.DB.DAO.DAORecordSetHelper
    DAO.Field System.Data.DataColumn
    DAO.Fields System.Data.DataColumnCollection
    DAO.Database System.Data.Common.DBConnection
    DAO.ParameterDirectionEnum System.Data.ParameterDirection
    DAO.Parameters System.Data.Common.DbParameterCollection
    DAO.Parameter

    System.Data.Common.DbParameter

    Example:

    System.Data.Common.DbParameter p = factory. CreateParameter();

    DAO.QueryDef System.Data.Common.DbCommand
    DAO.Connection System.Data.Common.DbConnection
    DAO.Workspace Artinsoft.VB6.DB.DAO.WorkspaceHelper
    DAO.DBEngine Artinsoft.VB6.DB.DAO.DBEngineHelper
    DAO.RecordsetTypeEnum Artinsoft.VB6.DB.DAO.DAORecordsetTypeEnum
    DAO.LockTypeEnum Artinsoft.VB6.DB.DAO.DAOLockTypeEnum
    DAO.RecordsetOptionEnum Artinsoft.VB6.DB.DAO.DAORecordsetOptionEnum

    A brief source sample of this feature:

    Original VB6 Code:

    Public recRecordset As DAO.Recordset
    Public dB As DAO.Database
    
    Private Sub Form_Load()
        
        Set dB = DBEngine.OpenDatabase(App.Path & "\TestDB.mdb")
        
        Set recRecordset = dB.OpenRecordset("Select * from Countries", DAO.dbOpenDynaset, DAO.dbConsistent, DAO.LockTypeEnum.dbOptimistic)
    
        recRecordset.Sort = "Name"
        recRecordset.MoveFirst
    
    End Sub

    Resulting VB.NET Code:

    Public recRecordset As DAORecordSetHelper
    Public dB As DbConnection
    
    Private Sub Form1_Load(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles MyBase.Load
    'UPGRADE_WARNING: (2065) DAO.DBEngine method DBEngine.OpenDatabase has a new behavior. More Information: http://www.vbtonet.com/ewis/ewi2065.aspx
        dB = DBEngineHelper.Instance(Artinsoft.VB6.DB.AdoFactoryManager.GetFactory()).OpenDatabase(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TestDB.mdb)
            
        recRecordset = DAORecordSetHelper.Open("Select * from Countries", dB, "")
        'UPGRADE_ISSUE: (2064) DAO.Recordset property recRecordset.Sort was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
    
        UpgradeStubs.DAO_Recordset.setSort(recRecordset, "Name")
        recRecordset.MoveFirst()
    End Sub

    Note that the connection String (gray highlight) was manually added after the automated migration stage.

    Resulting C#.NET Code:

    public DAORecordSetHelper recRecordset = null;
    public DbConnection dB = null;
    
    private void  Form1_Load( Object eventSender,  EventArgs eventArgs)
    {
        //UPGRADE_WARNING: (2065) DAO.DBEngine method DBEngine.OpenDatabase has a new behavior. More Information: http://www.vbtonet.com/ewis/ewi2065.aspx
        dB = DBEngineHelper.Instance(Artinsoft.VB6.DB.AdoFactoryManager.GetFactory()).OpenDatabase(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TestDB.mdb");
                        
        recRecordset = DAORecordSetHelper.Open("Select * from Countries", dB, "");
        //UPGRADE_ISSUE: (2064) DAO.Recordset property recRecordset.Sort was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        UpgradeStubs.DAO_Recordset.setSort(recRecordset, "Name");
        
        recRecordset.MoveFirst();
    }

    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration