Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a DTS package (SQL server)

Status
Not open for further replies.

MattN

Programmer
Jan 21, 2002
29
GB
I would like to execute a DTS package package using VB6.

Does anyone know the correct API to use.

A simple code example would be most appreciated.

Thanks in advance.

MattN
 
Assuming you have access to MSDN help, have a look at Package & Package2 objects and the Execute method under DTS programming.
 
And you will need to add Microsoft DTSPackage Object Library to your project references.
 
To execute a package from a VB app, the SQL Server client components have to be installed on the PC running your app.

This installs a COM component, and you can set a project reference to "Microsoft DTSPackage Object Library". It then take a few lines of code to execute the package:

Set dtsPackage = New DTS.Package
dtsPackage.LoadFromSQLServer ServerName:="MyServer", _
ServerUserName:="MyUserID", _
ServerPassword:="MyPassword", _
PackageName:="MyPackage"
dtsPackage.Execute

You can also create packages at runtime using this object library if that's appropriate.

Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top