Aracılığıyla paylaş


DtsErrors.GetEnumerator Yöntemi

Bir yönetilen verir ErrorEnumerator üzerinden numaralayıcı olabilir, DtsErrors koleksiyon.

Ad Alanı:  Microsoft.SqlServer.Dts.Runtime
Derleme:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS içinde.dll)

Sözdizimi

'Bildirim
Public Function GetEnumerator As ErrorEnumerator
'Kullanım
Dim instance As DtsErrors
Dim returnValue As ErrorEnumerator

returnValue = instance.GetEnumerator()
public ErrorEnumerator GetEnumerator()
public:
ErrorEnumerator^ GetEnumerator()
member GetEnumerator : unit -> ErrorEnumerator 
public function GetEnumerator() : ErrorEnumerator

Dönüş Değeri

Tür: Microsoft.SqlServer.Dts.Runtime.ErrorEnumerator
Bir ErrorEnumerator üzerinden yineleme için koleksiyon.

Örnekler

Aşağıdaki kod örneği, bir paket için bir görev ekler, sonra paketi çalıştırır.Uyarılar koleksiyon oluşturarak gösterilen bir ErrorEnumerator ve görüntüleme her hata açıklaması.

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 errors count before running:   {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 errors count after running the package:   {0}", package.Errors.Count);

            // Create the enumerator.
            ErrorEnumerator myEnumerator = package.Errors.GetEnumerator();
            Console.WriteLine("The collection contains the following values:");
            int i = 0;
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
                Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Description);
        }
    }
}
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 errors count before running:   {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 errors count after running the package:   {0}", package.Errors.Count)
 
            ' Create the enumerator.
            Dim myEnumerator As ErrorEnumerator =  package.Errors.GetEnumerator() 
            Console.WriteLine("The collection contains the following values:")
            Dim i As Integer =  0 
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)
            Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
            End While
        End Sub
    End Class
End Namespace

Örnek Çıktı:

Package errors count before running: 0

SendMailTask: {DE20010F-928A-4E9B-B57F-71D7991EC8F0}

Package errors count after running the package: 3

The collection contains the following values:

[0] SMTP Server not specified

[1] No recipient specified

[2] There were errors during task validation.