Export (0) Print
Expand All

Running a DTS Package Saved as a Visual Basic File

SQL Server 2000

Running a DTS Package Saved as a Visual Basic File

You can run a Data Transformation Services (DTS) package that has been saved by one of the DTS tools as a Microsoft® Visual Basic® file. The saved module, a Visual Basic .bas file, consists of declarations and a Sub Main and may contain other Subs called by Sub Main. The Subs contain all the logic of the DTS package.

Here are the basic steps for incorporating a Visual Basic module file into a Visual Basic project and executing it on a computer running the Microsoft SQL Server™ client tools:

  1. In Visual Basic, create a new Standard EXE project.

  2. On the Project menu, click References, and then select the Microsoft DTSDataPump Scripting Object Library, Microsoft DTSPackage Object Library, and Microsoft DTS Custom Tasks Object Library check boxes.

    Not all DTS programs will require all three of these libraries.

  3. On the Project menu, click Add File, and then add the Visual Basic file produced by the DTS Import/Export Wizard or DTS Designer.

  4. In the Project Explorer, select Form1 and then on the Project menu, click Remove Form1 to remove the blank form from the Project.

  5. Run the project. 

    No indication of completion will be given other than the Visual Basic Development Environment will go back to design mode.

You may want to add completion notification and error handling and controls to allow the user to invoke the transformation.

Using the Visual Basic File to Save to SQL Server

The Visual Basic project you created from the generated Visual Basic file can be used to save the DTS package to SQL Server.

Here are the basic steps for saving Visual Basic files to SQL Server:

  1. Go to the end of the Sub Main and uncomment the line
    'objPackage.SaveToSQLServer ...
    
  2. Comment out the following line
    objPackage.Execute
    
  3. Run the project.

    When the Visual Basic Development Environment goes back to design mode, the package is saved to SQL Server.

The package can now be edited, maintained, and run from DTS Designer. It can be saved again as a Visual Basic file from DTS Designer.

See Also

Executing DTS Packages in Visual Basic

Saving DTS Packages in Visual Basic

Saving a DTS Package to a Visual Basic File

Show:
© 2014 Microsoft