title: Error handling in DTS Package execution using .NET
body: <p>I am executing a SQL Server 2000 DTS package using C# by following the code from this article <a href="http://support.microsoft.com/kb/319985" rel="nofollow">http://support.microsoft.com/kb/319985</a>. once the package is executed I am looping through each step to find out if any step has failed and get info about error if it has failed. I also use this information to find out if the package has succeeded or not (package failed if anyone step has failed). 
      the issue I am facing here is that sometimes the package fails (jumps to catch block) with a generic error message that "Execution was canceled by user" and doesn't give any more information than that. If I run the package manually using the DTSRUNUI then I found that the package was expecting a text file as an input and the file didn't exist in the specified location. in that case the error message from .NET code should say that clearly. do I need to make any changes to the code from the article, to get more details about the errors. I added the following extra to get error information, but didn't help much. there are two properties called "FailonError" on package and "ExecuteInMainThread" on step objects. I tried setting them as well, but that also didn't help. not sure if they are required.</p>
  
  <pre><code>    bool success = true;
  if (package != null)
  {
      foreach (Step step in package.Steps)
      {
          if (step.ExecutionStatus == DTSStepExecStatus.DTSStepExecStat_Completed 
              &amp;&amp; step.ExecutionResult == DTSStepExecResult.DTSStepExecResult_Failure)
          {
              int errorCode, helpContext;
              string errorSource, errorDescription, helpFile, iDofInterfaceWithError;
  
              step.GetExecutionErrorInfo(out errorCode, out errorSource, out errorDescription, out helpFile,
                                         out helpContext, out iDofInterfaceWithError);
              LogToTextFile(
                  string.Format(
                      "step name: {0} error Code : {1}, error Source : {2}, error Description: {3}", step.Name,
                      errorCode, errorSource, errorDescription));
              success = false;
          }
      }
  }
  </code></pre>