本文介绍了VB6 - 如果连接失败,如何返回DTS错误的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB6中有一个DTS ...我想创建一个语句,如果我的DTS连接成功,如果没有,函数错误将返回值..请看下面的代码



我尝试过:



Module1.bas

I have a DTS in VB6...I want to create a statement if my DTS connection is successful and if not the function error will return the value..Please see my code below

What I have tried:

Module1.bas

Public Function Student()
      ....DTS Connection Details

   goPackage.Execute
   tracePackageError goPackage
   goPackage.UnInitialize

    End Function

     Public Function tracePackageError(Optional ByVal oPackage As DTS.Package) As String
          Dim ErrorCode As Long
          Dim ErrorSource As String
          Dim ErrorDescription As String
          Dim ErrorHelpFile As String
          Dim ErrorHelpContext As Long
          Dim ErrorIDofInterfaceWithError As String
          Dim i As Integer

For i = 1 To oPackage.Steps.Count            
     If oPackage.Steps(i).ExecutionResult = DTSStepExecResult_Failure Then
        oPackage.Steps(i).GetExecutionErrorInfo ErrorCode, ErrorSource,  ErrorDescription,ErrorHelpFile, ErrorHelpContext, ErrorIDofInterfaceWithError                                      
tracePackageError = oPackage.Steps(i).Name & " failed" & vbCrLf & ErrorSource & vbCrLf & ErrorDescription

Exit Function
End If
Next i
End Function



Form1


Form1

If tracePackageError <> "" Then
         MsgBox "error occured:" & vbCrLf & tracePackageError

         else
         Student
         Msgbox "Success!"
   End If

推荐答案


这篇关于VB6 - 如果连接失败,如何返回DTS错误的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 11:31