Friday, March 9, 2012

Run DTS Package from Visual Basic 6.3

Anyone have any code i can use to call a DTS package from Visual Basic. I would like to have an outlook macro that will run a dts package when i receive an email. All i need is the code that will call a dts package for a sql server that is not local to the box. I've tried this code but i get an error
run_tmie error '-2147217900 (80040e14)' automation error

Public Sub main()

Dim oPkg As DTS.Package2
Set oPkg = New DTS.Package2

oPkg.LoadFromSQLServer MyServerName, MyUserName, MyPassword, , MyDTSPackageName

oPkg.Execute
oPkg.UnInitialize

Set oPkg = Nothing

End Sub


Thanks in advance.I use the following in a VBScript. Will work in VB also.

strDTSRun_Command = "dtsrun.exe /Sservername /E /Ndtspackagename"
iWindowStyle = 10
bWaitOnReturn = true
Return = WshShell.Run(strDTSRun_Command, iWindowStyle, bWaitOnReturn)

No comments:

Post a Comment