''''以下是出错处理 Private Function ErrorNumConv(ByVal lngErrNum As Long) As String
If lngErrNum < 65536 And lngErrNum > -65536 Then ErrorNumConv = "x" & Hex(lngErrNum) & ", " & CStr(lngErrNum) Else ErrorNumConv = "x" & Hex(lngErrNum) & ", x" & _ Hex(lngErrNum And -65536) & " + " & CStr(lngErrNum And 65535) End If
End Function
Private Function AccumStepErrors(ByRef oPackage As DTS.Package) As String Dim oStep As DTS.Step Dim strMessage As String Dim lngErrNum As Long Dim strDescr As String Dim strSource As String
''''查找出错地 For Each oStep In oPackage.Steps If oStep.ExecutionStatus = DTSStepExecStat_Completed Then If oStep.ExecutionResult = DTSStepExecResult_Failure Then ''''得到出错信息 oStep.GetExecutionErrorInfo lngErrNum, strSource, strDescr strMessage = strMessage & vbCrLf & _ "Step " & oStep.Name & " failed, error: " & _ ErrorNumConv(lngErrNum) & vbCrLf & strDescr & vbCrLf End If End If Next AccumStepErrors = strMessage