Tutorials » How to run a DTS VB package in the .NET framework

Making the fixes

After the upgrade is done you can't simply compile the new project and run it. You'll get compiler errors that must be fixed. The rest of this article will dig into four types of issues:

  • Compile errors that you must fix to get the package working. We'll tell you how to fix them.
  • Warnings left as comments in the code. We'll tell you whether you need to worry about them or not.
  • Upgrade notes left as comments in the code. In general you should carefully consider these notes to ensure that the code is correct.
  • Conversions that took place as part of the upgrade. We'll review them as they illustrate the differences between Visual Basic 6.0 and Visual Basic .NET

How to fix the compiler errors

There are three errors that must be resolved before you can run the DTS package in the .NET environment. Fixing these problems should take no more then 10 minutes.

Compiler error #1 Argument not specified
Change:

    tracePackageError(goPackage.Steps.Item)

To:

    
tracePackageError(goPackage)

TracePackageError() takes a DTSPackage as an input argument, but the code that was generated tries to pass a Step object. Simply changing the argument to the container package solves the problem and allows the tracePackageError method to correctly walk through all the steps of the package.

Compiler error #2 and #3: Constructor call is valid only as the first statement in an instance constructor
The error message is a misleading. The solution is.
Change:

    
Public Sub Task_Sub1(ByVal goPackage As Object)
            :
        oTask = goPackage.Tasks.New("DTSDataPumpTask")


To:

    
Public Sub Task_Sub1(ByVal goPackage As DTS.Package2)
            :
        oTask = goPackage.Tasks.New("DTSDataPumpTask")

and change:

    
Public Sub oCustomTask1_Trans_Sub1(ByVal oCustomTask1 As Object)
            :
            oTransformation =
        oCustomTask1.Transformations.New("DTSPump.DataPumpTransformScript")


To:

    
Public Sub oCustomTask1_Trans_Sub1(ByVal oCustomTask1 As DTS.DataPumpTask2)
            :
            oTransformation =
        oCustomTask1.Transformations.New("DTSPump.DataPumpTransformScript"))
            :
            oTransformation =
        oCustomTask1.Transformations.New("DTSPump.DataPumpTransformScript"))

Both cases occur because a formal parameter is declared as a generic "Object." In Visual Basic 6.0 this worked because it took advantage of the default property that could be used as a shortcut in the code. Visual Basic .NET no longer supports the default property. The simple solution is to replace the "Object" formal parameter with the actual object required.

Contents

  1. Overview
  2. Introduction
  3. Making the fixes
  4. Warnings left in the code
  5. Summary
Previous Start Next
 
1 2 3 4 5