I am having problems executing packages remotely on the SQL server via VB. I can successfuly execute the package within Enterprise manager, and I can also save the DTS as a file and execute it without fail via VB. No errors are being thrown that I can see.
Here is my code:
' a sub for dts
Public Function SDDTS(ByRef Conx, ByRef SQLPass, ByRef SQLUser, ByRef DTSPass, ByRef DTSName) As Long
Dim sdStep As DTS.Step
Dim sdTask As DTS.Task
Dim sdExecPkg As DTS.ExecutePackageTask
'Creating the step and task.
'and link the step to the task.
Set sdStep = sdPackage.Steps.New
Set sdTask = sdPackage.Tasks.New("DTSExecutePackageTask")
Set sdExecPkg = sdTask.CustomTask
With sdExecPkg
.Name = "ExecPkgTask"
.ServerName = g_Conx
.UseTrustedConnection = True
.ServerUserName = g_SQL_User
.ServerPassword = g_SQL_Pass
.PackagePassword = g_DTS_Pass
.PackageName = "DTS_Test"
'.FileName = "D:\SQL\DTS_Test.dts" 'sDTSPackagePathAndFileName
.FileName = "DTS_Test"
End With
With sdStep
.TaskName = sdExecPkg.Name
.Name = "ExecPkgStep"
.ExecuteInMainThread = True
End With
'Add the step
sdPackage.Steps.Add sdStep
sdPackage.Tasks.Add sdTask
'
'cmdExecute.Enabled = False
'Running the package
sdPackage.Execute
'Clean up
Set sdExecPkg = Nothing
Set sdTask = Nothing
Set sdStep = Nothing
sdPackage.UnInitialize
End Function
Thanks!


Reply With Quote