다음을 통해 공유


DtsError.Source Property

Gets or sets the identifier of the object that caused the event.

네임스페이스: Microsoft.SqlServer.Dts.Runtime
어셈블리: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

구문

‘선언
Public Property Source As String
public string Source { get; set; }
public:
property String^ Source {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_Source ()

/** @property */
public void set_Source (String value)
public function get Source () : String

public function set Source (value : String)

속성 값

A String that contains the identifier to the source of the error.

The following code example adds a task to a package, sets some properties for the package. The package is then run, and properties for the errors and warnings found in the DtsWarnings and DtsErrors collections are shown.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.SendMailTask;

namespace Microsoft.SqlServer.SSIS.Samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Package package = new Package();
            Console.WriteLine("Package warnings count: {0}", package.Warnings.Count);
            Console.WriteLine("Package errors count:   {0}", package.Errors.Count);

            TaskHost taskH2 = (TaskHost)package.Executables.Add("STOCK:SendMailTask");
            taskH2.FailPackageOnFailure = false;
            taskH2.FailParentOnFailure = false;
            Console.WriteLine("SendMailTask: {0}", taskH2.ID);
 
            // Test that warnings were successfully added to the collection.
            package.MaximumErrorCount = 100;
            package.FailPackageOnFailure = false;
            package.FailParentOnFailure = false;
            package.DelayValidation = true;
            package.Execute();

            Console.WriteLine("Package warnings count after running the package: {0}", package.Warnings.Count);
            Console.WriteLine("Package errors count after running the package:   {0}", package.Errors.Cou
            foreach (DtsWarning pkgWarning in package.Warnings)
            {
                Console.WriteLine();
                Console.WriteLine("Description  {0}", pkgWarning.Description);
                Console.WriteLine("HelpContext  {0}", pkgWarning.HelpContext);
                Console.WriteLine("HelpFile     {0}", pkgWarning.HelpFile);
                Console.WriteLine("IDOfInterfaceWithWarning {0}", pkgWarning.IDOfInterfaceWithWarning);
                Console.WriteLine("Source       {0}", pkgWarning.Source);
                Console.WriteLine("Subcomponent {0}", pkgWarning.SubComponent);
                Console.WriteLine("Timestamp    {0}", pkgWarning.TimeStamp);
                Console.WriteLine("WarningCode  {0}", pkgWarning.WarningCode);
            }

            foreach (DtsError pkgError in package.Errors)
            {
                Console.WriteLine();
                Console.WriteLine("Description  {0}", pkgError.Description);
                Console.WriteLine("HelpContext  {0}", pkgError.HelpContext);
                Console.WriteLine("HelpFile     {0}", pkgError.HelpFile);
                Console.WriteLine("IDOfInterfaceWithError {0}", pkgError.IDOfInterfaceWithError);
                Console.WriteLine("Source       {0}", pkgError.Source);
                Console.WriteLine("Subcomponent {0}", pkgError.SubComponent);
                Console.WriteLine("Timestamp    {0}", pkgError.TimeStamp);
                Console.WriteLine("ErrorCode    {0}", pkgError.ErrorCode);
            }
            // Clear the errors and warnings collections.
            Console.WriteLine();
            package.Warnings.Clear();
            Console.WriteLine("Number of warnings after clearing: {0}", package.Warnings.Count);
            package.Errors.Clear();
            Console.WriteLine("Number of Errors after clearing: {0}", package.Errors.Count);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.SendMailTask
 
Namespace Microsoft.SqlServer.SSIS.Samples
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim package As Package =  New Package() 
            Console.WriteLine("Package warnings count: {0}", package.Warnings.Count)
            Console.WriteLine("Package errors count:   {0}", package.Errors.Count)
 
            Dim taskH2 As TaskHost = CType(package.Executables.Add("STOCK:SendMailTask"), TaskHost)
            taskH2.FailPackageOnFailure = False
            taskH2.FailParentOnFailure = False
            Console.WriteLine("SendMailTask: {0}", taskH2.ID)
 
            ' Test that warnings were successfully added to the collection.
            package.MaximumErrorCount = 100
            package.FailPackageOnFailure = False
            package.FailParentOnFailure = False
            package.DelayValidation = True
            package.Execute()
 
            Console.WriteLine("Package warnings count after running the package: {0}", package.Warnings.Count)
            Console.WriteLine("Package errors count after running the package:   {0}", package.Errors.Cou
            Dim pkgWarning As DtsWarning
            For Each pkgWarning In package.Warnings
                Console.WriteLine()
                Console.WriteLine("Description  {0}", pkgWarning.Description)
                Console.WriteLine("HelpContext  {0}", pkgWarning.HelpContext)
                Console.WriteLine("HelpFile     {0}", pkgWarning.HelpFile)
                Console.WriteLine("IDOfInterfaceWithWarning {0}", pkgWarning.IDOfInterfaceWithWarning)
                Console.WriteLine("Source       {0}", pkgWarning.Source)
                Console.WriteLine("Subcomponent {0}", pkgWarning.SubComponent)
                Console.WriteLine("Timestamp    {0}", pkgWarning.TimeStamp)
                Console.WriteLine("WarningCode  {0}", pkgWarning.WarningCode)
            Next
 
            Dim pkgError As DtsError
            For Each pkgError In package.Errors
                Console.WriteLine()
                Console.WriteLine("Description  {0}", pkgError.Description)
                Console.WriteLine("HelpContext  {0}", pkgError.HelpContext)
                Console.WriteLine("HelpFile     {0}", pkgError.HelpFile)
                Console.WriteLine("IDOfInterfaceWithError {0}", pkgError.IDOfInterfaceWithError)
                Console.WriteLine("Source       {0}", pkgError.Source)
                Console.WriteLine("Subcomponent {0}", pkgError.SubComponent)
                Console.WriteLine("Timestamp    {0}", pkgError.TimeStamp)
                Console.WriteLine("ErrorCode    {0}", pkgError.ErrorCode)
            Next
            ' Clear the errors and warnings collections.
            Console.WriteLine()
            package.Warnings.Clear()
            Console.WriteLine("Number of warnings after clearing: {0}", package.Warnings.Count)
            package.Errors.Clear()
            Console.WriteLine("Number of Errors after clearing: {0}", package.Errors.Count)
        End Sub
    End Class
End Namespace

Sample Output:

Package warnings count after running the package: 2

Package errors count after running the package: 3

Description The address in the From line is not formed correctly. It is missing an @ or it is not valid.

HelpContext 0

HelpFile

IDOfInterfaceWithWarning {8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}

Source {1E9FF017-4E01-4AEF-8519-4D48D954D3D1}

Subcomponent Send Mail Task

Timestamp 4/13/2005 5:24:42 PM

WarningCode 0

Description Subject is empty

HelpContext 0

HelpFile

IDOfInterfaceWithWarning {8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}

Source {1E9FF017-4E01-4AEF-8519-4D48D954D3D1}

Subcomponent Send Mail Task

Timestamp 4/13/2005 5:24:42 PM

WarningCode 0

Description SMTP Server not specified

HelpContext 0

HelpFile

IDOfInterfaceWithError {8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}

Source {1E9FF017-4E01-4AEF-8519-4D48D954D3D1}

Subcomponent Send Mail Task

Timestamp 4/13/2005 5:24:42 PM

ErrorCode 0

Description No recipient specified

HelpContext 0

HelpFile

IDOfInterfaceWithError {8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}

Source {1E9FF017-4E01-4AEF-8519-4D48D954D3D1}

Subcomponent Send Mail Task

Timestamp 4/13/2005 5:24:42 PM

ErrorCode 0

Description There were errors during task validation.

HelpContext -1073594105

HelpFile

IDOfInterfaceWithError {8BDFE889-E9D8-4D23-9739-DA807BCDC2AC}

Source {1E9FF017-4E01-4AEF-8519-4D48D954D3D1}

Subcomponent

Timestamp 4/13/2005 5:24:42 PM

ErrorCode -1073594105

Number of warnings after clearing: 0

Number of Errors after clearing: 0

스레드 보안

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

플랫폼

개발 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

대상 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

DtsError Class
DtsError Members
Microsoft.SqlServer.Dts.Runtime Namespace