by Raju Maharjan
6. November 2010 14:21
We can run a DTS package that is saved by DTS tools as a Microsoft Visual Basic (.bas) file. A Visual Basic .bas file consists of declarations and a Sub Main and may contain other Subs called by Sub Main with all logic of the DTS package.
Steps for using a Visual Basic module (.bas) file into a Visual Basic project and executing it on a computer running the Microsoft SQL Server™ client tools:
- Create a new Standard EXE project.
- On the Project menu, select References, and then add references to Microsoft DTSDataPumpScripting Object Library, Microsoft DTSPackage Object Library, andMicrosoft DTS Custom Tasks Object Library check boxes.
- On the Project menu, click Add File, and then add the Visual Basic file produced by the DTS Import/Export Wizard or DTS Designer.
- In the Project Explorer, Remove Form1 from the Project menu
- Run the project.
There will be No indication of completion but Visual Basic Development Environment will go back to design mode.
The Visual Basic project generated Visual Basic file from above can be used to save the DTS package to SQL Server.
Steps for saving Visual Basic files to SQL Server:
- Go to the end of the Sub Main of Visual Basis File and uncomment the line
'goPackage.SaveToSQLServer "(local)", "sa", ""
- Comment out the following line
objPackage.Execute
- Run the project.
As the Visual Basic Development Environment goes back to design mode, the package is saved to SQL Server.
The package can now be run from DTS Designer and can be saved again as a Visual Basic file from DTS Designer.