Not sure if this should be in the Access VBA forum or SQL Forum so I will try here first.
I am running a DTS from within an Access module and trapping errors to display to the user if the package has ran ok.
The code I have is as follows:
Function ExecPackage(sPackageName As String) As Boolean
Dim oPKG As DTS.Package, oStep As DTS.Step
Set oPKG = New DTS.Package
varReturn = SysCmd(acSysCmdSetStatus, "Running DTS Package..."
Dim sServer As String
Dim sMessage As String
Dim lErr As Long, sSource As String, sDesc As String
' Set Parameter Values
sServer = "Server"
' Load Package
oPKG.LoadFromSQLServer sServer, , , _
DTSSQLStgFlag_UseTrustedConnection, , , , sPackageName
' Set Exec on Main Thread
For Each oStep In oPKG.Steps
oStep.ExecuteInMainThread = True
Next
oPKG.Execute
' Get Status and Error Message
For Each oStep In oPKG.Steps
If oStep.ExecutionResult = DTSStepExecResult_Success Then
oStep.GetExecutionErrorInfo lErr, sSource, sDesc
Debug.Print sMessage & " " & oStep.Description & " Successfull"
End If
If oStep.ExecutionResult = DTSStepExecResult_Failure Then
oStep.GetExecutionErrorInfo lErr, sSource, sDesc
Debug.Print sMessage & " " & oStep.Description
& " Failed"
End If
Next
oPKG.UnInitialize
Set oStep = Nothing
Set oPKG = Nothing
End Function
The DTS package name is passed to the function and for testing purposes, I am looking at the messages in the debug window. This code runs fine showing all steps in the DTS but it is not displayed in the running order of the DTS.
Is there any way I can change the code so that displays in the order that the DTS runs?. From that I could take the first failure to display to the User where the DTS has failed (ie.Importing of a file failed or writting file to history, etc.)
Thanks
I am running a DTS from within an Access module and trapping errors to display to the user if the package has ran ok.
The code I have is as follows:
Function ExecPackage(sPackageName As String) As Boolean
Dim oPKG As DTS.Package, oStep As DTS.Step
Set oPKG = New DTS.Package
varReturn = SysCmd(acSysCmdSetStatus, "Running DTS Package..."
Dim sServer As String
Dim sMessage As String
Dim lErr As Long, sSource As String, sDesc As String
' Set Parameter Values
sServer = "Server"
' Load Package
oPKG.LoadFromSQLServer sServer, , , _
DTSSQLStgFlag_UseTrustedConnection, , , , sPackageName
' Set Exec on Main Thread
For Each oStep In oPKG.Steps
oStep.ExecuteInMainThread = True
Next
oPKG.Execute
' Get Status and Error Message
For Each oStep In oPKG.Steps
If oStep.ExecutionResult = DTSStepExecResult_Success Then
oStep.GetExecutionErrorInfo lErr, sSource, sDesc
Debug.Print sMessage & " " & oStep.Description & " Successfull"
End If
If oStep.ExecutionResult = DTSStepExecResult_Failure Then
oStep.GetExecutionErrorInfo lErr, sSource, sDesc
Debug.Print sMessage & " " & oStep.Description
& " Failed"
End If
Next
oPKG.UnInitialize
Set oStep = Nothing
Set oPKG = Nothing
End Function
The DTS package name is passed to the function and for testing purposes, I am looking at the messages in the debug window. This code runs fine showing all steps in the DTS but it is not displayed in the running order of the DTS.
Is there any way I can change the code so that displays in the order that the DTS runs?. From that I could take the first failure to display to the User where the DTS has failed (ie.Importing of a file failed or writting file to history, etc.)
Thanks