Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Feb 10, 2003

How to run a DTS VB package in the .NET framework - Page 2

By DatabaseJournal.com Staff

James Horne

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

Three errors 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 walk through all the steps of the package correctly.

Compiler error #2 and #3: Constructor call is valid only as the first statement in an instance constructor

The error message is 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.



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM


















Thanks for your registration, follow us on our social networks to keep up-to-date